C++ API Reference for Intel® Data Analytics Acceleration Library 2019

logitboost_training_batch.h
1 /* file: logitboost_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 LogitBoost model-based training
19 //--
20 */
21 
22 #ifndef __LOGIT_BOOST_TRAINING_BATCH_H__
23 #define __LOGIT_BOOST_TRAINING_BATCH_H__
24 
25 #include "algorithms/boosting/boosting_training_batch.h"
26 #include "algorithms/boosting/logitboost_training_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace logitboost
33 {
34 namespace training
35 {
36 
37 namespace interface1
38 {
52 template<typename algorithmFPType, Method method, CpuType cpu>
53 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
54 {
55 public:
61  BatchContainer(daal::services::Environment::env *daalEnv);
63  ~BatchContainer();
67  services::Status compute() DAAL_C11_OVERRIDE;
68 };
69 
87 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = friedman>
88 class DAAL_EXPORT Batch : public boosting::training::Batch
89 {
90 public:
91  typedef boosting::training::Batch super;
92 
93  typedef typename super::InputType InputType;
94  typedef algorithms::logitboost::Parameter ParameterType;
95  typedef algorithms::logitboost::training::Result ResultType;
96 
97  ParameterType parameter;
98  InputType input;
104  Batch(size_t nClasses)
105  {
106  initialize();
107  parameter.nClasses = nClasses;
108  }
109 
116  Batch(const Batch<algorithmFPType, method> &other) : boosting::training::Batch(other),
117  parameter(other.parameter), input(other.input)
118  {
119  initialize();
120  }
121 
122  virtual ~Batch() {}
123 
128  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
129 
134  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
135 
140  ResultPtr getResult()
141  {
142  return ResultType::cast(_result);
143  }
144 
148  services::Status resetResult() DAAL_C11_OVERRIDE
149  {
150  _result.reset(new ResultType());
151  DAAL_CHECK(_result, services::ErrorNullResult);
152  _res = NULL;
153  return services::Status();
154  }
155 
161  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
162  {
163  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
164  }
165 
166 protected:
167  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
168  {
169  return new Batch<algorithmFPType, method>(*this);
170  }
171 
172  services::Status allocateResult() DAAL_C11_OVERRIDE
173  {
174  ResultPtr res = getResult();
175  DAAL_CHECK(_result, services::ErrorNullResult);
176  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
177  _res = _result.get();
178  return s;
179  }
180 
181  void initialize()
182  {
183  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
184  _in = &input;
185  _par = &parameter;
186  _result.reset(new ResultType());
187  }
188 };
190 } // namespace interface1
191 using interface1::BatchContainer;
192 using interface1::Batch;
193 
194 } // namespace daal::algorithms::logitboost::training
195 }
196 }
197 } // namespace daal
198 #endif // __LOGIT_BOOST_TRAINING_BATCH_H__
daal
Definition: algorithm_base_common.h:31
daal::algorithms::logitboost::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logitboost_training_batch.h:161
daal::algorithms::logitboost::training::interface1::Batch::Batch
Batch(size_t nClasses)
Definition: logitboost_training_batch.h:104
daal::algorithms::logitboost::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:148
daal::algorithms::logitboost::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: logitboost_training_batch.h:116
daal::batch
Definition: daal_defines.h:106
daal::algorithms::logitboost::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:134
daal::algorithms::logitboost::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: logitboost_training_batch.h:140
daal::algorithms::logitboost::training::interface1::Batch::parameter
ParameterType parameter
Definition: logitboost_training_batch.h:97
daal::algorithms::logitboost::training::interface1::Batch::input
InputType input
Definition: logitboost_training_batch.h:98
daal::algorithms::logitboost::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:128
daal::algorithms::logitboost::training::interface1::Batch
Trains model of the LogitBoost algorithms in the batch processing mode.
Definition: logitboost_training_batch.h:88
daal::algorithms::logitboost::training::interface1::BatchContainer
Provides methods to run implementations of LogitBoost model-based training. This class is associated ...
Definition: logitboost_training_batch.h:53
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.