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

decision_forest_classification_training_batch.h
1 /* file: decision_forest_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 forest model-based training
21 //--
22 */
23 
24 #ifndef __DECISION_FOREST_CLASSIFICATION_TRAINING_BATCH_H__
25 #define __DECISION_FOREST_CLASSIFICATION_TRAINING_BATCH_H__
26 
27 #include "algorithms/classifier/classifier_training_batch.h"
28 #include "algorithms/decision_forest/decision_forest_classification_training_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace decision_forest
35 {
36 namespace classification
37 {
38 namespace training
39 {
40 namespace interface1
41 {
55 template<typename algorithmFPType, Method method, CpuType cpu>
56 class BatchContainer : public TrainingContainerIface<batch>
57 {
58 public:
64  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
66  DAAL_DEPRECATED~BatchContainer();
71  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
72  DAAL_DEPRECATED services::Status setupCompute() DAAL_C11_OVERRIDE;
73 };
74 
92 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
93 class DAAL_EXPORT Batch : public classifier::training::interface1::Batch
94 {
95 public:
96  typedef classifier::training::interface1::Batch super;
97 
98  typedef typename super::InputType InputType;
99  typedef algorithms::decision_forest::classification::training::interface1::Parameter ParameterType;
100  typedef algorithms::decision_forest::classification::training::Result ResultType;
101 
102  ParameterType parameter;
103  InputType input;
109  DAAL_DEPRECATED Batch(size_t nClasses) : parameter(nClasses)
110  {
111  initialize();
112  parameter.minObservationsInLeafNode = 1;
113  }
114 
121  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) : classifier::training::interface1::Batch(other),
122  parameter(other.parameter), input(other.input)
123  {
124  initialize();
125  }
126 
127  DAAL_DEPRECATED_VIRTUAL virtual ~Batch() {}
128 
133  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
134 
139  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
140 
145  DAAL_DEPRECATED ResultPtr getResult()
146  {
147  return ResultType::cast(_result);
148  }
149 
153  DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
154  {
155  _result.reset(new ResultType());
156  DAAL_CHECK(_result, services::ErrorNullResult);
157  _res = NULL;
158  return services::Status();
159  }
160 
166  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
167  {
168  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
169  }
170 
171  DAAL_DEPRECATED_VIRTUAL virtual services::Status checkComputeParams() DAAL_C11_OVERRIDE;
172 
173 protected:
174  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
175  {
176  return new Batch<algorithmFPType, method>(*this);
177  }
178 
179  services::Status allocateResult() DAAL_C11_OVERRIDE
180  {
181  ResultPtr res = getResult();
182  DAAL_CHECK(res, services::ErrorNullResult);
183  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
184  _res = _result.get();
185  return s;
186  }
187 
188  void initialize()
189  {
190  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
191  _in = &input;
192  _par = &parameter;
193  _result.reset(new ResultType());
194  }
195 };
197 } // namespace interface1
198 
199 namespace interface2
200 {
214 template<typename algorithmFPType, Method method, CpuType cpu>
215 class BatchContainer : public TrainingContainerIface<batch>
216 {
217 public:
223  BatchContainer(daal::services::Environment::env *daalEnv);
225  ~BatchContainer();
230  services::Status compute() DAAL_C11_OVERRIDE;
231  services::Status setupCompute() DAAL_C11_OVERRIDE;
232 };
233 
251 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
252 class DAAL_EXPORT Batch : public classifier::training::Batch
253 {
254 public:
255  typedef classifier::training::Batch super;
256 
257  typedef typename super::InputType InputType;
258  typedef algorithms::decision_forest::classification::training::Parameter ParameterType;
259  typedef algorithms::decision_forest::classification::training::Result ResultType;
260 
261  ParameterType parameter;
262  InputType input;
268  Batch(size_t nClasses) : parameter(nClasses)
269  {
270  initialize();
271  parameter.minObservationsInLeafNode = 1;
272  }
273 
280  Batch(const Batch<algorithmFPType, method> &other) : classifier::training::Batch(other),
281  parameter(other.parameter), input(other.input)
282  {
283  initialize();
284  }
285 
286  virtual ~Batch() {}
287 
292  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
293 
298  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
299 
304  ResultPtr getResult()
305  {
306  return ResultType::cast(_result);
307  }
308 
312  services::Status resetResult() DAAL_C11_OVERRIDE
313  {
314  _result.reset(new ResultType());
315  DAAL_CHECK(_result, services::ErrorNullResult);
316  _res = NULL;
317  return services::Status();
318  }
319 
325  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
326  {
327  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
328  }
329 
330  virtual services::Status checkComputeParams() DAAL_C11_OVERRIDE;
331 
332 protected:
333  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
334  {
335  return new Batch<algorithmFPType, method>(*this);
336  }
337 
338  services::Status allocateResult() DAAL_C11_OVERRIDE
339  {
340  ResultPtr res = getResult();
341  DAAL_CHECK(res, services::ErrorNullResult);
342  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
343  _res = _result.get();
344  return s;
345  }
346 
347  void initialize()
348  {
349  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
350  _in = &input;
351  _par = &parameter;
352  _result.reset(new ResultType());
353  }
354 };
356 } // namespace interface2
357 using interface2::BatchContainer;
358 using interface2::Batch;
359 
360 } // namespace daal::algorithms::decision_forest::classification::training
361 }
362 }
363 }
364 } // namespace daal
365 #endif // __LOGIT_BOOST_TRAINING_BATCH_H__
daal::algorithms::decision_forest::classification::training::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
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_forest::classification::training::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::batch
Definition: daal_defines.h:112
daal::algorithms::decision_forest::classification::training::interface2::Batch
Trains model of the Decision forest algorithms in the batch processing mode.
Definition: decision_forest_classification_training_batch.h:252
daal::algorithms::decision_forest::classification::training::interface2::BatchContainer
Provides methods to run implementations of Decision forest model-based training. This class is associ...
Definition: decision_forest_classification_training_batch.h:215
daal::algorithms::classifier::training::interface1::Batch
Algorithm class for training the classifier model.
Definition: classifier_training_batch.h:58
daal::algorithms::decision_forest::classification::training::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::decision_forest::classification::training::interface1::Batch::input
InputType input
Definition: decision_forest_classification_training_batch.h:103
daal::algorithms::decision_forest::classification::training::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_forest_classification_training_batch.h:280
daal::algorithms::decision_forest::classification::training::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_forest_classification_training_batch.h:325
daal::algorithms::decision_forest::classification::training::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:298
daal::algorithms::decision_forest::classification::training::interface2::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:312
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:93
daal::algorithms::decision_forest::classification::training::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:292
daal::algorithms::decision_forest::classification::training::interface2::Batch::input
InputType input
Definition: decision_forest_classification_training_batch.h:262
daal::algorithms::decision_forest::classification::training::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_forest_classification_training_batch.h:166
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::decision_forest::classification::training::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:139
daal::algorithms::decision_forest::classification::training::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::decision_forest::classification::training::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
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_forest::classification::training::interface1::Batch::parameter
ParameterType parameter
Definition: decision_forest_classification_training_batch.h:102
daal::algorithms::decision_forest::classification::training::interface2::Batch::parameter
ParameterType parameter
Definition: decision_forest_classification_training_batch.h:261
daal::algorithms::decision_forest::classification::training::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:133
daal::algorithms::decision_forest::classification::training::interface1::Batch::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: decision_forest_classification_training_batch.h:145
daal::algorithms::decision_forest::classification::training::interface2::Batch::getResult
ResultPtr getResult()
Definition: decision_forest_classification_training_batch.h:304
daal::algorithms::decision_forest::classification::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nClasses)
Definition: decision_forest_classification_training_batch.h:109
daal::algorithms::decision_forest::classification::training::interface1::Parameter
Decision forest algorithm parameters.
Definition: decision_forest_classification_training_types.h:97
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:56
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::decision_forest::classification::training::interface2::Batch::Batch
Batch(size_t nClasses)
Definition: decision_forest_classification_training_batch.h:268
daal::algorithms::decision_forest::classification::training::interface1::Batch::resetResult
DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_training_batch.h:153
daal::algorithms::decision_forest::classification::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_forest_classification_training_batch.h:121
daal::algorithms::decision_forest::classification::training::interface2::BatchContainer::~BatchContainer
~BatchContainer()

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