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

decision_forest_classification_training_batch.h
1 /* file: decision_forest_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 forest model-based training
19 //--
20 */
21 
22 #ifndef __DECISION_FOREST_CLASSIFICATION_TRAINING_BATCH_H__
23 #define __DECISION_FOREST_CLASSIFICATION_TRAINING_BATCH_H__
24 
25 #include "algorithms/classifier/classifier_training_batch.h"
26 #include "algorithms/decision_forest/decision_forest_classification_training_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace decision_forest
33 {
34 namespace classification
35 {
36 namespace training
37 {
38 namespace interface1
39 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
55 {
56 public:
62  BatchContainer(daal::services::Environment::env *daalEnv);
64  ~BatchContainer();
69  services::Status compute() DAAL_C11_OVERRIDE;
70  services::Status setupCompute() DAAL_C11_OVERRIDE;
71 };
72 
90 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
91 class DAAL_EXPORT Batch : public classifier::training::Batch
92 {
93 public:
94  typedef classifier::training::Batch super;
95 
96  typedef typename super::InputType InputType;
97  typedef algorithms::decision_forest::classification::training::Parameter ParameterType;
98  typedef algorithms::decision_forest::classification::training::Result ResultType;
99 
100  ParameterType parameter;
101  InputType input;
107  Batch(size_t nClasses) : parameter(nClasses)
108  {
109  initialize();
110  parameter.minObservationsInLeafNode = 1;
111  }
112 
119  Batch(const Batch<algorithmFPType, method> &other) : classifier::training::Batch(other),
120  parameter(other.parameter), input(other.input)
121  {
122  initialize();
123  }
124 
125  virtual ~Batch() {}
126 
131  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
132 
137  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
138 
143  ResultPtr getResult()
144  {
145  return ResultType::cast(_result);
146  }
147 
151  services::Status resetResult() DAAL_C11_OVERRIDE
152  {
153  _result.reset(new ResultType());
154  DAAL_CHECK(_result, services::ErrorNullResult);
155  _res = NULL;
156  return services::Status();
157  }
158 
164  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
165  {
166  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
167  }
168 
169  virtual services::Status checkComputeParams() DAAL_C11_OVERRIDE;
170 
171 protected:
172  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
173  {
174  return new Batch<algorithmFPType, method>(*this);
175  }
176 
177  services::Status allocateResult() DAAL_C11_OVERRIDE
178  {
179  ResultPtr res = getResult();
180  DAAL_CHECK(res, services::ErrorNullResult);
181  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
182  _res = _result.get();
183  return s;
184  }
185 
186  void initialize()
187  {
188  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
189  _in = &input;
190  _par = &parameter;
191  _result.reset(new ResultType());
192  }
193 };
195 } // namespace interface1
196 using interface1::BatchContainer;
197 using interface1::Batch;
198 
199 } // namespace daal::algorithms::decision_forest::classification::training
200 }
201 }
202 }
203 } // namespace daal
204 #endif // __LOGIT_BOOST_TRAINING_BATCH_H__
daal::algorithms::decision_forest::classification::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:131
daal
Definition: algorithm_base_common.h:31
daal::algorithms::decision_forest::classification::training::interface1::Batch::parameter
ParameterType parameter
Definition: decision_forest_classification_training_batch.h:100
daal::algorithms::decision_forest::classification::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_forest_classification_training_batch.h:164
daal::algorithms::decision_forest::classification::training::interface1::BatchContainer
Provides methods to run implementations of Decision forest model-based training. This class is associ...
Definition: decision_forest_classification_training_batch.h:54
daal::batch
Definition: daal_defines.h:110
daal::algorithms::decision_forest::classification::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: decision_forest_classification_training_batch.h:143
daal::algorithms::decision_forest::classification::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:137
daal::algorithms::decision_forest::classification::training::interface1::Batch
Trains model of the Decision forest algorithms in the batch processing mode.
Definition: decision_forest_classification_training_batch.h:91
daal::algorithms::decision_forest::classification::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_forest_classification_training_batch.h:119
daal::algorithms::decision_forest::classification::training::interface1::Batch::Batch
Batch(size_t nClasses)
Definition: decision_forest_classification_training_batch.h:107
daal::algorithms::decision_forest::classification::training::interface1::Batch::input
InputType input
Definition: decision_forest_classification_training_batch.h:101
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::decision_forest::classification::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:151
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50

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