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

gbt_regression_training_batch.h
1 /* file: gbt_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 model-based training
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __GBT_REGRESSSION_TRAINING_BATCH_H__
26 #define __GBT_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/gradient_boosted_trees/gbt_regression_training_types.h"
33 #include "algorithms/gradient_boosted_trees/gbt_regression_model.h"
34 #include "algorithms/regression/regression_training_batch.h"
35 
36 namespace daal
37 {
38 namespace algorithms
39 {
40 namespace gbt
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::gbt::regression::training::Input InputType;
98  typedef algorithms::gbt::regression::training::Parameter ParameterType;
99  typedef algorithms::gbt::regression::training::Result ResultType;
100 
101  InputType input;
104  Batch();
105 
112  Batch(const Batch<algorithmFPType, method> &other);
113 
115  ~Batch()
116  {
117  delete _par;
118  }
119 
124  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
125 
130  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
131 
136  virtual algorithms::regression::training::Input* getInput() DAAL_C11_OVERRIDE{ return &input; }
137 
142  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
143 
148  ResultPtr getResult() { return ResultType::cast(_result); }
149 
150  /* Resets the results of the regression model-based training
151  * \return Status of the operation
152  */
153  virtual 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  }
166  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
167  {
168  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
169  }
170 
171 protected:
172 
173  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
174  {
175  return new Batch<algorithmFPType, method>(*this);
176  }
177 
178  services::Status allocateResult() DAAL_C11_OVERRIDE
179  {
180  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter(), method);
181  _res = _result.get();
182  return s;
183  }
184 
185  void initialize()
186  {
187  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
188  _in = &input;
189  _result.reset(new ResultType());
190  }
191 };
193 } // namespace interface1
194 using interface1::BatchContainer;
195 using interface1::Batch;
196 }
197 }
198 }
199 }
200 }
201 #endif
daal::algorithms::gbt::regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: gbt_regression_training_batch.h:148
daal::algorithms::gbt::regression::training::interface1::Batch::getInput
virtual algorithms::regression::training::Input * getInput() DAAL_C11_OVERRIDE
Definition: gbt_regression_training_batch.h:136
daal::batch
Definition: daal_defines.h:112
daal::algorithms::gbt::regression::training::interface1::Batch
Provides methods for model-based training in the batch processing mode.
Definition: gbt_regression_training_batch.h:94
daal::algorithms::gbt::regression::training::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::gbt::regression::training::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: gbt_regression_training_batch.h:130
daal::algorithms::gbt::regression::training::interface1::Batch::input
InputType input
Definition: gbt_regression_training_batch.h:101
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::gbt::regression::training::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::gbt::regression::training::interface1::BatchContainer
Class containing methods for gradient boosted trees regression model-based training using algorithmFP...
Definition: gbt_regression_training_batch.h:59
daal::algorithms::gbt::regression::training::interface1::Batch::~Batch
~Batch()
Definition: gbt_regression_training_batch.h:115
daal_defines.h
daal::algorithms::gbt::regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: gbt_regression_training_batch.h:142
daal::algorithms::gbt::regression::training::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::gbt::regression::training::interface1::Batch::parameter
ParameterType & parameter()
Definition: gbt_regression_training_batch.h:124
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.