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

decision_tree_classification_training_batch.h
1 /* file: decision_tree_classification_training_batch.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 the interface for Decision tree model-based training in the batch processing mode
19 //--
20 */
21 
22 #ifndef __DECISION_TREE_CLASSIFICATION_TRAINING_BATCH_H__
23 #define __DECISION_TREE_CLASSIFICATION_TRAINING_BATCH_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/decision_tree/decision_tree_classification_training_types.h"
27 #include "algorithms/decision_tree/decision_tree_classification_model.h"
28 #include "algorithms/classifier/classifier_training_batch.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace decision_tree
35 {
36 namespace classification
37 {
38 namespace training
39 {
40 namespace interface1
41 {
52 template <typename algorithmFPType, Method method, CpuType cpu>
53 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
54 {
55 public:
60  BatchContainer(daal::services::Environment::env * daalEnv);
61 
63  ~BatchContainer();
64 
68  services::Status compute() DAAL_C11_OVERRIDE;
69 };
70 
86 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
87 class DAAL_EXPORT Batch : public classifier::training::Batch
88 {
89 public:
90  typedef classifier::training::Batch super;
91 
92  typedef algorithms::decision_tree::classification::training::Input InputType;
93  typedef algorithms::decision_tree::classification::Parameter ParameterType;
94  typedef algorithms::decision_tree::classification::training::Result ResultType;
95 
96 
97  InputType input;
98  ParameterType parameter;
101  Batch(size_t nClasses) : parameter(nClasses)
102  {
103  initialize();
104  }
105 
111  Batch(const Batch<algorithmFPType, method> & other) : classifier::training::Batch(other), input(other.input), parameter(other.parameter)
112  {
113  initialize();
114  }
115 
120  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
121 
126  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
127 
132  ResultPtr getResult() { return ResultType::cast(_result); }
133 
137  services::Status resetResult() DAAL_C11_OVERRIDE
138  {
139  _result.reset(new ResultType());
140  DAAL_CHECK(_result, services::ErrorNullResult);
141  _res = NULL;
142  return services::Status();
143  }
144 
151  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
152  {
153  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
154  }
155 
156 protected:
157  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
158  {
159  return new Batch<algorithmFPType, method>(*this);
160  }
161 
162  services::Status allocateResult() DAAL_C11_OVERRIDE
163  {
164  ResultPtr res = getResult();
165  DAAL_CHECK(res, services::ErrorNullResult);
166  services::Status s = res->template allocate<algorithmFPType>((classifier::training::InputIface *)(&input), &parameter, (int)method);
167  _res = _result.get();
168  return s;
169  }
170 
171  void initialize()
172  {
173  _in = &input;
174  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
175  _par = &parameter;
176  _result.reset(new ResultType());
177  }
178 };
179 
181 } // namespace interface1
182 
183 using interface1::BatchContainer;
184 using interface1::Batch;
185 
186 } // namespace training
187 } // namespace classification
188 } // namespace decision_tree
189 } // namespace algorithms
190 } // namespace daal
191 
192 #endif
daal::algorithms::decision_tree::classification::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:120
daal::algorithms::decision_tree::classification::training::interface1::Batch
Provides methods for Decision tree model-based training in the batch processing mode.
Definition: decision_tree_classification_training_batch.h:87
daal
Definition: algorithm_base_common.h:31
daal::algorithms::decision_tree::classification::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_tree_classification_training_batch.h:151
daal::algorithms::decision_tree::classification::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:137
daal::algorithms::decision_tree::classification::training::interface1::Batch::parameter
ParameterType parameter
Definition: decision_tree_classification_training_batch.h:98
daal::batch
Definition: daal_defines.h:110
daal::algorithms::decision_tree::classification::training::interface1::BatchContainer
Class containing methods for Decision tree model-based training using algorithmFPType precision arith...
Definition: decision_tree_classification_training_batch.h:53
daal::algorithms::decision_tree::classification::training::interface1::Batch::Batch
Batch(size_t nClasses)
Definition: decision_tree_classification_training_batch.h:101
daal::algorithms::decision_tree::classification::training::interface1::Batch::input
InputType input
Definition: decision_tree_classification_training_batch.h:97
daal::algorithms::decision_tree::classification::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_tree_classification_training_batch.h:111
daal::algorithms::decision_tree::classification::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:126
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50
daal::algorithms::decision_tree::classification::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: decision_tree_classification_training_batch.h:132

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