C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 5

gbt_classification_model_builder.h
1 /* file: gbt_classification_model_builder.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of class defining gradient boosting trees classification model builder.
19 //--
20 */
21 #ifndef __GBT_CLASSIFICATION_MODEL_BUILDER_H__
22 #define __GBT_CLASSIFICATION_MODEL_BUILDER_H__
23 
24 #include "algorithms/gradient_boosted_trees/gbt_classification_model.h"
25 
26 namespace daal
27 {
28 namespace algorithms
29 {
30 namespace gbt
31 {
40 namespace classification
41 {
45 namespace interface1
46 {
58 class DAAL_EXPORT ModelBuilder
59 {
60 public:
64  typedef size_t NodeId;
65 
69  typedef size_t TreeId;
70 
71  static const NodeId noParent = static_cast<size_t>(-1);
79  ModelBuilder(size_t nFeatures, size_t nIterations, size_t nClasses = 2)
80  {
81  _status |= initialize(nFeatures, nIterations, nClasses);
82  services::throwIfPossible(_status);
83  }
84 
91  TreeId createTree(size_t nNodes, size_t classLabel)
92  {
93  TreeId resId;
94  _status |= createTreeInternal(nNodes, classLabel, resId);
95  services::throwIfPossible(_status);
96  return resId;
97  }
98 
107  NodeId addLeafNode(TreeId treeId, NodeId parentId, size_t position, double response)
108  {
109  NodeId resId;
110  _status |= addLeafNodeInternal(treeId, parentId, position, response, resId);
111  services::throwIfPossible(_status);
112  return resId;
113  }
114 
124  NodeId addSplitNode(TreeId treeId, NodeId parentId, size_t position, size_t featureIndex, double featureValue)
125  {
126  NodeId resId;
127  _status |= addSplitNodeInternal(treeId, parentId, position, featureIndex, featureValue, resId);
128  services::throwIfPossible(_status);
129  return resId;
130  }
131 
136  ModelPtr getModel()
137  {
138  _status |= convertModelInternal();
139  services::throwIfPossible(_status);
140  return _model;
141  }
142 
147  services::Status getStatus()
148  {
149  return _status;
150  }
151 
152 protected:
153  ModelPtr _model;
154  services::Status _status;
155  services::Status initialize(size_t nFeatures, size_t nIterations, size_t nClasses);
156  services::Status createTreeInternal(size_t nNodes, size_t classLabel, TreeId& resId);
157  services::Status addLeafNodeInternal(TreeId treeId, NodeId parentId, size_t position, double response, NodeId& res);
158  services::Status addSplitNodeInternal(TreeId treeId, NodeId parentId, size_t position, size_t featureIndex, double featureValue, NodeId& res);
159  services::Status convertModelInternal();
160  size_t _nClasses;
161  size_t _nIterations;
162 
163 };
165 } // namespace interface1
166 using interface1::ModelBuilder;
167 
168 } // namespace classification
169 } // namespace gbt
170 } // namespace algorithms
171 } // namespace daal
172 #endif
daal::algorithms::gbt::classification::interface1::ModelBuilder::getModel
ModelPtr getModel()
Definition: gbt_classification_model_builder.h:136
daal
Definition: algorithm_base_common.h:31
daal::algorithms::gbt::classification::interface1::ModelBuilder::NodeId
size_t NodeId
Node identifier type is size_t
Definition: gbt_classification_model_builder.h:64
daal::algorithms::em_gmm::nIterations
Definition: em_gmm_types.h:97
daal::algorithms::gbt::classification::interface1::ModelBuilder::addSplitNode
NodeId addSplitNode(TreeId treeId, NodeId parentId, size_t position, size_t featureIndex, double featureValue)
Definition: gbt_classification_model_builder.h:124
daal::algorithms::gbt::classification::interface1::ModelBuilder::addLeafNode
NodeId addLeafNode(TreeId treeId, NodeId parentId, size_t position, double response)
Definition: gbt_classification_model_builder.h:107
daal::algorithms::gbt::classification::interface1::ModelBuilder::getStatus
services::Status getStatus()
Definition: gbt_classification_model_builder.h:147
daal::algorithms::gbt::classification::interface1::ModelBuilder::ModelBuilder
ModelBuilder(size_t nFeatures, size_t nIterations, size_t nClasses=2)
Definition: gbt_classification_model_builder.h:79
daal::algorithms::gbt::classification::interface1::ModelBuilder::TreeId
size_t TreeId
Tree identifier type is size_t
Definition: gbt_classification_model_builder.h:69
daal::algorithms::gbt::classification::interface1::ModelBuilder::createTree
TreeId createTree(size_t nNodes, size_t classLabel)
Definition: gbt_classification_model_builder.h:91
daal::algorithms::gbt::classification::interface1::ModelBuilder
Model Builder class for gradient boosted trees classification model.
Definition: gbt_classification_model_builder.h:58

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