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

decision_forest_regression_training_batch.h
1 /* file: decision_forest_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 forest model-based training
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __DECISION_FOREST_REGRESSSION_TRAINING_BATCH_H__
26 #define __DECISION_FOREST_REGRESSSION_TRAINING_BATCH_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "services/daal_memory.h"
32 #include "algorithms/decision_forest/decision_forest_regression_training_types.h"
33 #include "algorithms/decision_forest/decision_forest_regression_model.h"
34 #include "algorithms/regression/regression_training_batch.h"
35 
36 namespace daal
37 {
38 namespace algorithms
39 {
40 namespace decision_forest
41 {
42 namespace regression
43 {
44 namespace training
45 {
46 namespace interface1
47 {
58 template<typename algorithmFPType, Method method, CpuType cpu>
59 class BatchContainer : public TrainingContainerIface<batch>
60 {
61 public:
67  BatchContainer(daal::services::Environment::env *daalEnv);
69  ~BatchContainer();
74  services::Status compute() DAAL_C11_OVERRIDE;
75  services::Status setupCompute() DAAL_C11_OVERRIDE;
76 };
77 
93 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
94 class DAAL_EXPORT Batch : public algorithms::regression::training::Batch
95 {
96 public:
97  typedef algorithms::decision_forest::regression::training::Input InputType;
98  typedef algorithms::decision_forest::regression::training::Parameter ParameterType;
99  typedef algorithms::decision_forest::regression::training::Result ResultType;
100 
101  InputType input;
102  ParameterType parameter;
105  Batch() : parameter()
106  {
107  initialize();
108  parameter.minObservationsInLeafNode = 5;
109  }
110 
117  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
118  {
119  initialize();
120  }
121 
122  ~Batch() {}
123 
124  virtual algorithms::regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
125 
130  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
131 
136  ResultPtr getResult() { return ResultType::cast(_result); }
137 
141  services::Status resetResult() DAAL_C11_OVERRIDE
142  {
143  _result.reset(new ResultType());
144  DAAL_CHECK(_result, services::ErrorNullResult);
145  _res = NULL;
146  return services::Status();
147  }
148 
155  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
156  {
157  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
158  }
159 
160 protected:
161 
162  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
163  {
164  return new Batch<algorithmFPType, method>(*this);
165  }
166 
167  services::Status allocateResult() DAAL_C11_OVERRIDE
168  {
169  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
170  _res = _result.get();
171  return s;
172  }
173 
174  void initialize()
175  {
176  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
177  _in = &input;
178  _par = &parameter;
179  _result.reset(new ResultType());
180  }
181 };
183 } // namespace interface1
184 using interface1::BatchContainer;
185 using interface1::Batch;
186 }
187 }
188 }
189 }
190 }
191 #endif
daal::algorithms::decision_forest::regression::training::interface1::Batch
Provides methods for decision forest model-based training in the batch processing mode...
Definition: decision_forest_regression_training_batch.h:94
daal::batch
Definition: daal_defines.h:112
daal::algorithms::decision_forest::regression::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_forest_regression_training_batch.h:117
daal::algorithms::decision_forest::regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_forest_regression_training_batch.h:130
daal::algorithms::decision_forest::regression::training::interface1::Batch::input
InputType input
Definition: decision_forest_regression_training_batch.h:101
daal::algorithms::decision_forest::regression::training::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::decision_forest::regression::training::interface1::Batch::Batch
Batch()
Definition: decision_forest_regression_training_batch.h:105
daal::algorithms::decision_forest::regression::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: decision_forest_regression_training_batch.h:141
daal_defines.h
daal::algorithms::decision_forest::regression::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_forest_regression_training_batch.h:155
daal::algorithms::decision_forest::regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: decision_forest_regression_training_batch.h:136
daal::algorithms::decision_forest::regression::training::interface1::Batch::parameter
ParameterType parameter
Definition: decision_forest_regression_training_batch.h:102
daal::algorithms::decision_forest::regression::training::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
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::regression::training::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::decision_forest::regression::training::interface1::BatchContainer
Class containing methods for decision forest regression model-based training using algorithmFPType pr...
Definition: decision_forest_regression_training_batch.h:59

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