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

decision_tree_regression_training_batch.h
1 /* file: decision_tree_regression_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_REGRESSION_TRAINING_BATCH_H__
25 #define __DECISION_TREE_REGRESSION_TRAINING_BATCH_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/decision_tree/decision_tree_regression_training_types.h"
29 #include "algorithms/decision_tree/decision_tree_regression_model.h"
30 #include "algorithms/regression/regression_training_batch.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace decision_tree
37 {
38 namespace regression
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 algorithms::regression::training::Batch
90 {
91 public:
92  typedef algorithms::regression::training::Batch super;
93 
94  typedef algorithms::decision_tree::regression::training::Input InputType;
95  typedef algorithms::decision_tree::regression::Parameter ParameterType;
96  typedef algorithms::decision_tree::regression::training::Result ResultType;
97 
98  InputType input;
99  ParameterType parameter;
102  DAAL_DEPRECATED Batch()
103  {
104  initialize();
105  }
106 
112  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> & other) :
113  algorithms::regression::training::Batch(other), input(other.input), parameter(other.parameter)
114  {
115  initialize();
116  }
117 
118  DAAL_DEPRECATED_VIRTUAL virtual algorithms::regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
119 
124  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
125 
130  DAAL_DEPRECATED ResultPtr getResult() { return ResultType::cast(_result); }
131 
135  DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
136  {
137  _result.reset(new ResultType());
138  DAAL_CHECK(_result, services::ErrorNullResult);
139  _res = NULL;
140  return services::Status();
141  }
142 
149  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
150  {
151  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
152  }
153 
154 protected:
155  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
156  {
157  return new Batch<algorithmFPType, method>(*this);
158  }
159 
160  services::Status allocateResult() DAAL_C11_OVERRIDE
161  {
162  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
163  _res = _result.get();
164  return s;
165  }
166 
167  void initialize()
168  {
169  _in = &input;
170  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
171  _par = &parameter;
172  _result.reset(new ResultType());
173  }
174 };
176 } // namespace interface1
177 
178 namespace interface2
179 {
190 template <typename algorithmFPType, Method method, CpuType cpu>
191 class BatchContainer : public TrainingContainerIface<batch>
192 {
193 public:
198  BatchContainer(daal::services::Environment::env * daalEnv);
199 
201  ~BatchContainer();
202 
206  services::Status compute() DAAL_C11_OVERRIDE;
207 };
208 
224 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
225 class DAAL_EXPORT Batch : public algorithms::regression::training::Batch
226 {
227 public:
228  typedef algorithms::regression::training::Batch super;
229 
230  typedef algorithms::decision_tree::regression::training::Input InputType;
231  typedef algorithms::decision_tree::regression::Parameter ParameterType;
232  typedef algorithms::decision_tree::regression::training::Result ResultType;
233 
234  InputType input;
235  ParameterType parameter;
238  Batch()
239  {
240  initialize();
241  }
242 
248  Batch(const Batch<algorithmFPType, method> & other) :
249  algorithms::regression::training::Batch(other), input(other.input), parameter(other.parameter)
250  {
251  initialize();
252  }
253 
254  virtual algorithms::regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
255 
260  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
261 
266  ResultPtr getResult() { return ResultType::cast(_result); }
267 
271  services::Status resetResult() DAAL_C11_OVERRIDE
272  {
273  _result.reset(new ResultType());
274  DAAL_CHECK(_result, services::ErrorNullResult)
275  _res = NULL;
276  return services::Status();
277  }
278 
285  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
286  {
287  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
288  }
289 
290 protected:
291  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
292  {
293  return new Batch<algorithmFPType, method>(*this);
294  }
295 
296  services::Status allocateResult() DAAL_C11_OVERRIDE
297  {
298  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
299  _res = _result.get();
300  return s;
301  }
302 
303  void initialize()
304  {
305  _in = &input;
306  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
307  _par = &parameter;
308  _result.reset(new ResultType());
309  }
310 };
312 }
313 
314 using interface2::BatchContainer;
315 using interface2::Batch;
316 
317 } // namespace training
318 } // namespace regression
319 } // namespace decision_tree
320 } // namespace algorithms
321 } // namespace daal
322 
323 #endif
daal::algorithms::decision_tree::regression::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_tree_regression_training_batch.h:112
daal::algorithms::decision_tree::regression::training::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::decision_tree::regression::training::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_tree_regression_training_batch.h:248
daal::algorithms::decision_tree::regression::training::interface1::Batch::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: decision_tree_regression_training_batch.h:130
daal::batch
Definition: daal_defines.h:112
daal::algorithms::decision_tree::regression::training::interface1::Batch
Provides methods for Decision tree model-based training in the batch processing mode.
Definition: decision_tree_regression_training_batch.h:89
daal::algorithms::decision_tree::regression::training::interface2::Batch::getResult
ResultPtr getResult()
Definition: decision_tree_regression_training_batch.h:266
daal::algorithms::decision_tree::regression::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: decision_tree_regression_training_batch.h:102
daal::algorithms::decision_tree::regression::training::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_tree_regression_training_batch.h:285
daal::algorithms::decision_tree::regression::training::interface1::Batch::input
InputType input
Definition: decision_tree_regression_training_batch.h:98
daal::algorithms::decision_tree::regression::training::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_tree_regression_training_batch.h:149
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::decision_tree::regression::training::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::decision_tree::regression::training::interface2::Batch::parameter
ParameterType parameter
Definition: decision_tree_regression_training_batch.h:235
daal::algorithms::decision_tree::regression::training::interface2::Batch
Provides methods for Decision tree model-based training in the batch processing mode.
Definition: decision_tree_regression_training_batch.h:225
daal::algorithms::decision_tree::regression::training::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::decision_tree::regression::training::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::decision_tree::regression::training::interface2::BatchContainer
Class containing methods for Decision tree model-based training using algorithmFPType precision arith...
Definition: decision_tree_regression_training_batch.h:191
daal::algorithms::decision_tree::regression::training::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_tree_regression_training_batch.h:124
daal::algorithms::decision_tree::regression::training::interface2::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_tree_regression_training_batch.h:271
daal::algorithms::decision_tree::regression::training::interface1::BatchContainer
Class containing methods for Decision tree model-based training using algorithmFPType precision arith...
Definition: decision_tree_regression_training_batch.h:55
daal::algorithms::decision_tree::regression::training::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_tree_regression_training_batch.h:260
daal::algorithms::decision_tree::regression::training::interface2::Batch::input
InputType input
Definition: decision_tree_regression_training_batch.h:234
daal::algorithms::decision_tree::regression::training::interface2::Batch::Batch
Batch()
Definition: decision_tree_regression_training_batch.h:238
daal::algorithms::decision_tree::regression::training::interface1::Batch::resetResult
DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_tree_regression_training_batch.h:135
daal::algorithms::decision_tree::regression::training::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::decision_tree::regression::training::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
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_tree::regression::training::interface1::Batch::parameter
ParameterType parameter
Definition: decision_tree_regression_training_batch.h:99

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