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

decision_tree_classification_training_batch.h
1 /* file: decision_tree_classification_training_batch.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 interface for Decision tree model-based training in the batch processing mode
21 //--
22 */
23 
24 #ifndef __DECISION_TREE_CLASSIFICATION_TRAINING_BATCH_H__
25 #define __DECISION_TREE_CLASSIFICATION_TRAINING_BATCH_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/decision_tree/decision_tree_classification_training_types.h"
29 #include "algorithms/decision_tree/decision_tree_classification_model.h"
30 #include "algorithms/classifier/classifier_training_batch.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace decision_tree
37 {
38 namespace classification
39 {
40 namespace training
41 {
42 namespace interface1
43 {
54 template <typename algorithmFPType, Method method, CpuType cpu>
55 class BatchContainer : public TrainingContainerIface<batch>
56 {
57 public:
62  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env * daalEnv);
63 
65  DAAL_DEPRECATED ~BatchContainer();
66 
70  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
71 };
72 
88 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
89 class DAAL_EXPORT Batch : public classifier::training::interface1::Batch
90 {
91 public:
92  typedef classifier::training::interface1::Batch super;
93 
94  typedef algorithms::decision_tree::classification::training::Input InputType;
95  typedef algorithms::decision_tree::classification::interface1::Parameter ParameterType;
96  typedef algorithms::decision_tree::classification::training::Result ResultType;
97 
98  InputType input;
99  ParameterType parameter;
102  DAAL_DEPRECATED Batch(size_t nClasses) : parameter(nClasses)
103  {
104  initialize();
105  }
106 
112  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> & other) : classifier::training::interface1::Batch(other), input(other.input), parameter(other.parameter)
113  {
114  initialize();
115  }
116 
121  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
122 
127  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
128 
133  DAAL_DEPRECATED ResultPtr getResult() { return ResultType::cast(_result); }
134 
138  DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
139  {
140  _result.reset(new ResultType());
141  DAAL_CHECK(_result, services::ErrorNullResult);
142  _res = NULL;
143  return services::Status();
144  }
145 
152  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
153  {
154  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
155  }
156 
157 protected:
158  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
159  {
160  return new Batch<algorithmFPType, method>(*this);
161  }
162 
163  services::Status allocateResult() DAAL_C11_OVERRIDE
164  {
165  ResultPtr res = getResult();
166  DAAL_CHECK(res, services::ErrorNullResult);
167  services::Status s = res->template allocate<algorithmFPType>((classifier::training::InputIface *)(&input), &parameter, (int)method);
168  _res = _result.get();
169  return s;
170  }
171 
172  void initialize()
173  {
174  _in = &input;
175  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
176  _par = &parameter;
177  _result.reset(new ResultType());
178  }
179 };
180 
182 } // namespace interface1
183 
184 namespace interface2
185 {
196 template <typename algorithmFPType, Method method, CpuType cpu>
197 class BatchContainer : public TrainingContainerIface<batch>
198 {
199 public:
204  BatchContainer(daal::services::Environment::env * daalEnv);
205 
207  ~BatchContainer();
208 
212  services::Status compute() DAAL_C11_OVERRIDE;
213 };
214 
230 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
231 class DAAL_EXPORT Batch : public classifier::training::Batch
232 {
233 public:
234  typedef classifier::training::Batch super;
235 
236  typedef algorithms::decision_tree::classification::training::Input InputType;
237  typedef algorithms::decision_tree::classification::Parameter ParameterType;
238  typedef algorithms::decision_tree::classification::training::Result ResultType;
239 
240 
241  InputType input;
242  ParameterType parameter;
245  Batch(size_t nClasses) : parameter(nClasses)
246  {
247  initialize();
248  }
249 
255  Batch(const Batch<algorithmFPType, method> & other) : classifier::training::Batch(other), input(other.input), parameter(other.parameter)
256  {
257  initialize();
258  }
259 
264  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
265 
270  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
271 
276  ResultPtr getResult() { return ResultType::cast(_result); }
277 
281  services::Status resetResult() DAAL_C11_OVERRIDE
282  {
283  _result.reset(new ResultType());
284  DAAL_CHECK(_result, services::ErrorNullResult);
285  _res = NULL;
286  return services::Status();
287  }
288 
295  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
296  {
297  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
298  }
299 
300 protected:
301  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
302  {
303  return new Batch<algorithmFPType, method>(*this);
304  }
305 
306  services::Status allocateResult() DAAL_C11_OVERRIDE
307  {
308  ResultPtr res = getResult();
309  DAAL_CHECK(res, services::ErrorNullResult);
310  services::Status s = res->template allocate<algorithmFPType>((classifier::training::InputIface *)(&input), &parameter, (int)method);
311  _res = _result.get();
312  return s;
313  }
314 
315  void initialize()
316  {
317  _in = &input;
318  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
319  _par = &parameter;
320  _result.reset(new ResultType());
321  }
322 };
323 
325 }
326 
327 using interface2::BatchContainer;
328 using interface2::Batch;
329 
330 
331 } // namespace training
332 } // namespace classification
333 } // namespace decision_tree
334 } // namespace algorithms
335 } // namespace daal
336 
337 #endif
daal::algorithms::decision_tree::classification::training::interface2::Batch
Provides methods for Decision tree model-based training in the batch processing mode.
Definition: decision_tree_classification_training_batch.h:231
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:55
daal::algorithms::classifier::training::interface1::Result
Provides methods to access final results obtained with the compute() method in the batch processing m...
Definition: classifier_training_types.h:198
daal::algorithms::decision_tree::classification::training::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::batch
Definition: daal_defines.h:112
daal::algorithms::decision_tree::classification::training::interface1::Batch::resetResult
DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:138
daal::algorithms::decision_tree::classification::training::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::classifier::training::interface1::Batch
Algorithm class for training the classifier model.
Definition: classifier_training_batch.h:58
daal::algorithms::decision_tree::classification::training::interface1::Batch::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: decision_tree_classification_training_batch.h:133
daal::algorithms::decision_tree::classification::training::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::decision_tree::classification::training::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_tree_classification_training_batch.h:255
daal::algorithms::decision_tree::classification::training::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:127
daal::algorithms::decision_tree::classification::training::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::decision_tree::classification::training::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::decision_tree::classification::training::interface2::Batch::getResult
ResultPtr getResult()
Definition: decision_tree_classification_training_batch.h:276
daal::algorithms::decision_tree::classification::training::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:121
daal::algorithms::decision_tree::classification::interface1::Parameter
Decision tree algorithm parameters.
Definition: decision_tree_classification_model.h:84
daal::algorithms::decision_tree::classification::training::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_tree_classification_training_batch.h:295
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::decision_tree::classification::training::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::decision_tree::classification::training::interface2::Batch::Batch
Batch(size_t nClasses)
Definition: decision_tree_classification_training_batch.h:245
daal::algorithms::decision_tree::classification::training::interface2::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:281
daal::algorithms::decision_tree::classification::training::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:264
daal::algorithms::decision_tree::classification::training::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_tree_classification_training_batch.h:270
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:89
daal::algorithms::decision_tree::classification::training::interface2::Batch::parameter
ParameterType parameter
Definition: decision_tree_classification_training_batch.h:242
daal::algorithms::decision_tree::classification::training::interface1::Batch::parameter
ParameterType parameter
Definition: decision_tree_classification_training_batch.h:99
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::classifier::training::interface1::Input
Base class for the input objects in the training stage of the classification algorithms.
Definition: classifier_training_types.h:110
daal::algorithms::decision_tree::classification::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_tree_classification_training_batch.h:112
daal::algorithms::decision_tree::classification::training::interface2::BatchContainer
Class containing methods for Decision tree model-based training using algorithmFPType precision arith...
Definition: decision_tree_classification_training_batch.h:197
daal::algorithms::decision_tree::classification::training::interface1::Batch::input
InputType input
Definition: decision_tree_classification_training_batch.h:98
daal::algorithms::decision_tree::classification::training::interface2::Batch::input
InputType input
Definition: decision_tree_classification_training_batch.h:241
daal::algorithms::decision_tree::classification::training::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_tree_classification_training_batch.h:152
daal::algorithms::decision_tree::classification::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nClasses)
Definition: decision_tree_classification_training_batch.h:102
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52

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