C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

decision_tree_classification_model.h
1 /* file: decision_tree_classification_model.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of the class defining the Decision tree classification model
21 //--
22 */
23 
24 #ifndef __DECISION_TREE_CLASSIFICATION_MODEL_H__
25 #define __DECISION_TREE_CLASSIFICATION_MODEL_H__
26 
27 #include "algorithms/classifier/classifier_model.h"
28 #include "algorithms/classifier/tree_traverse.h"
29 #include "data_management/data/aos_numeric_table.h"
30 #include "data_management/data/soa_numeric_table.h"
31 #include "data_management/data/homogen_numeric_table.h"
32 #include "decision_tree_model.h"
33 #include "algorithms/tree_utils/tree_utils_classification.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 
49 namespace decision_tree
50 {
51 
55 namespace classification
56 {
57 
62 enum SplitCriterion
63 {
64  gini = 0,
65  infoGain = 1
66 };
67 
71 namespace interface1
72 {
83 /* [interface1::Parameter source code] */
84 struct DAAL_EXPORT Parameter : public daal::algorithms::classifier::interface1::Parameter
85 {
90  DAAL_DEPRECATED Parameter(size_t nClasses = 2) : daal::algorithms::classifier::interface1::Parameter(nClasses),
91  pruning(reducedErrorPruning), maxTreeDepth(0), minObservationsInLeafNodes(1),
92  splitCriterion(infoGain) {}
93 
97  DAAL_DEPRECATED services::Status check() const DAAL_C11_OVERRIDE;
98 
99  SplitCriterion splitCriterion;
100  Pruning pruning;
101  size_t maxTreeDepth;
102  size_t minObservationsInLeafNodes;
103 };
104 /* [interface1::Parameter source code] */
105 
115 class DAAL_EXPORT Model : public daal::algorithms::classifier::Model
116 {
117 public:
118  DECLARE_MODEL_IFACE(Model, classifier::Model);
119 
125  Model(size_t nFeatures = 0);
126 
132  static services::SharedPtr<Model> create(size_t nFeatures = 0, services::Status *stat = NULL);
133 
134  virtual ~Model();
135 
136  class ModelImpl;
137  typedef services::SharedPtr<ModelImpl> ModelImplPtr;
138 
143  const ModelImpl * impl() const { return _impl.get(); }
144 
149  ModelImpl * impl() { return _impl.get(); }
150 
155  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
156 
162  void traverseDF(classifier::TreeNodeVisitor& visitor) const;
163 
169  void traverseBF(classifier::TreeNodeVisitor& visitor) const;
170 
175  void traverseDFS(tree_utils::classification::interface1::TreeNodeVisitor& visitor) const;
176 
181  void traverseBFS(tree_utils::classification::interface1::TreeNodeVisitor& visitor) const;
182 
187  void traverseDFS(tree_utils::classification::TreeNodeVisitor& visitor) const;
188 
193  void traverseBFS(tree_utils::classification::TreeNodeVisitor& visitor) const;
194 
195 protected:
196  Model(size_t nFeatures, services::Status &st);
197 
198  services::Status serializeImpl(data_management::InputDataArchive * arch) DAAL_C11_OVERRIDE;
199 
200  services::Status deserializeImpl(const data_management::OutputDataArchive * arch) DAAL_C11_OVERRIDE;
201 
202 private:
203  ModelImplPtr _impl;
204 };
205 
206 typedef services::SharedPtr<Model> ModelPtr;
207 typedef services::SharedPtr<const Model> ModelConstPtr;
208 
209 } // namespace interface1
210 
211 using interface1::Model;
212 using interface1::ModelPtr;
213 using interface1::ModelConstPtr;
214 
218 namespace interface2
219 {
230 /* [Parameter source code] */
231 struct DAAL_EXPORT Parameter : public daal::algorithms::classifier::Parameter
232 {
237  Parameter(size_t nClasses = 2) : daal::algorithms::classifier::Parameter(nClasses),
238  pruning(reducedErrorPruning), maxTreeDepth(0), minObservationsInLeafNodes(1),
239  nBins(1),
240  splitCriterion(infoGain) {}
241 
245  services::Status check() const DAAL_C11_OVERRIDE;
246 
247  SplitCriterion splitCriterion;
248  Pruning pruning;
249  size_t maxTreeDepth;
250  size_t minObservationsInLeafNodes;
251  size_t nBins;
253 };
254 /* [Parameter source code] */
255 }
256 using interface2::Parameter;
257 
259 } // namespace classification
260 } // namespace decision_tree
261 } // namespace algorithms
262 } // namespace daal
263 
264 #endif
daal::algorithms::decision_tree::classification::SplitCriterion
SplitCriterion
Split criterion for Decision tree classification algorithm.
Definition: decision_tree_classification_model.h:62
daal::algorithms::decision_tree::reducedErrorPruning
Definition: decision_tree_model.h:52
daal::algorithms::decision_tree::classification::interface1::Parameter
Decision tree algorithm parameters.
Definition: decision_tree_classification_model.h:84
daal::algorithms::decision_tree::classification::interface2::Parameter::Parameter
Parameter(size_t nClasses=2)
Definition: decision_tree_classification_model.h:237
daal::algorithms::decision_tree::classification::interface2::Parameter
Decision tree algorithm parameters.
Definition: decision_tree_classification_model.h:231
daal::algorithms::decision_tree::Pruning
Pruning
Pruning method for Decision tree algorithm.
Definition: decision_tree_model.h:49
daal::algorithms::decision_tree::classification::interface1::Model::impl
const ModelImpl * impl() const
Definition: decision_tree_classification_model.h:143
daal::algorithms::decision_tree::classification::interface1::Parameter::Parameter
DAAL_DEPRECATED Parameter(size_t nClasses=2)
Definition: decision_tree_classification_model.h:90
daal::algorithms::decision_tree::classification::interface1::Model
Base class for models trained with the Decision tree algorithm
Definition: decision_tree_classification_model.h:115
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::decision_tree::classification::interface1::Model::impl
ModelImpl * impl()
Definition: decision_tree_classification_model.h:149
daal::algorithms::decision_tree::classification::gini
Definition: decision_tree_classification_model.h:64
daal::algorithms::decision_tree::classification::infoGain
Definition: decision_tree_classification_model.h:65

For more complete information about compiler optimizations, see our Optimization Notice.