C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 3

gbt_classification_training_batch.h
1 /* file: gbt_classification_training_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for Gradient Boosted Trees model-based training
19 //--
20 */
21 
22 #ifndef __GBT_CLASSIFICATION_TRAINING_BATCH_H__
23 #define __GBT_CLASSIFICATION_TRAINING_BATCH_H__
24 
25 #include "algorithms/classifier/classifier_training_batch.h"
26 #include "algorithms/gradient_boosted_trees/gbt_classification_training_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace gbt
33 {
34 namespace classification
35 {
36 namespace training
37 {
38 namespace interface1
39 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
55 {
56 public:
62  BatchContainer(daal::services::Environment::env *daalEnv);
64  ~BatchContainer();
69  services::Status compute() DAAL_C11_OVERRIDE;
70  services::Status setupCompute() DAAL_C11_OVERRIDE;
71 };
72 
90 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
91 class DAAL_EXPORT Batch : public classifier::training::Batch
92 {
93 public:
94  typedef classifier::training::Batch super;
95 
96  typedef typename super::InputType InputType;
97  typedef algorithms::gbt::classification::training::Parameter ParameterType;
98  typedef algorithms::gbt::classification::training::Result ResultType;
99 
100  InputType input;
106  Batch(size_t nClasses)
107  {
108  _par = new ParameterType(nClasses);
109  initialize();
110  }
111 
118  Batch(const Batch<algorithmFPType, method> &other) : classifier::training::Batch(other), input(other.input)
119  {
120  _par = new ParameterType(other.parameter());
121  initialize();
122  }
123 
125  ~Batch()
126  {
127  delete _par;
128  }
129 
134  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
135 
140  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
141 
146  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
147 
152  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
153 
158  ResultPtr getResult()
159  {
160  return ResultType::cast(_result);
161  }
162 
166  services::Status resetResult() DAAL_C11_OVERRIDE
167  {
168  _result.reset(new ResultType());
169  DAAL_CHECK(_result, services::ErrorNullResult);
170  _res = NULL;
171  return services::Status();
172  }
173 
179  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
180  {
181  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
182  }
183 
184  virtual services::Status checkComputeParams() DAAL_C11_OVERRIDE;
185 
186 protected:
187  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
188  {
189  return new Batch<algorithmFPType, method>(*this);
190  }
191 
192  services::Status allocateResult() DAAL_C11_OVERRIDE
193  {
194  ResultPtr res = getResult();
195  DAAL_CHECK(res, services::ErrorNullResult);
196  services::Status s = res->template allocate<algorithmFPType>(&input, &parameter(), method);
197  _res = _result.get();
198  return s;
199  }
200 
201  void initialize()
202  {
203  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
204  _in = &input;
205  _result.reset(new ResultType());
206  }
207 };
209 } // namespace interface1
210 using interface1::BatchContainer;
211 using interface1::Batch;
212 
213 } // namespace daal::algorithms::gbt::classification::training
214 }
215 }
216 }
217 } // namespace daal
218 #endif // __LOGIT_BOOST_TRAINING_BATCH_H__
daal::algorithms::gbt::classification::training::interface1::BatchContainer
Provides methods to run implementations of Gradient Boosted Trees model-based training. This class is associated with daal::algorithms::gbt::classification::training::Batch class.
Definition: gbt_classification_training_batch.h:54
daal
Definition: algorithm_base_common.h:31
daal::algorithms::gbt::classification::training::interface1::Batch::~Batch
~Batch()
Definition: gbt_classification_training_batch.h:125
daal::algorithms::gbt::classification::training::interface1::Batch::parameter
ParameterType & parameter()
Definition: gbt_classification_training_batch.h:134
daal::algorithms::gbt::classification::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: gbt_classification_training_batch.h:146
daal::algorithms::gbt::classification::training::interface1::Batch::Batch
Batch(size_t nClasses)
Definition: gbt_classification_training_batch.h:106
daal::batch
Definition: daal_defines.h:106
daal::algorithms::gbt::classification::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: gbt_classification_training_batch.h:158
daal::algorithms::gbt::classification::training::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: gbt_classification_training_batch.h:140
daal::algorithms::gbt::classification::training::interface1::Batch
Trains model of the Gradient Boosted Trees algorithms in the batch processing mode.
Definition: gbt_classification_training_batch.h:91
daal::algorithms::gbt::classification::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: gbt_classification_training_batch.h:179
daal::algorithms::gbt::classification::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: gbt_classification_training_batch.h:166
daal::algorithms::gbt::classification::training::interface1::Batch::input
InputType input
Definition: gbt_classification_training_batch.h:100
daal::algorithms::gbt::classification::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: gbt_classification_training_batch.h:118
daal::algorithms::gbt::classification::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: gbt_classification_training_batch.h:152
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50

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