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

logitboost_training_batch.h
1 /* file: logitboost_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 LogitBoost model-based training
21 //--
22 */
23 
24 #ifndef __LOGIT_BOOST_TRAINING_BATCH_H__
25 #define __LOGIT_BOOST_TRAINING_BATCH_H__
26 
27 #include "algorithms/boosting/boosting_training_batch.h"
28 #include "algorithms/boosting/logitboost_training_types.h"
29 #include "algorithms/classifier/classifier_training_batch.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace logitboost
36 {
37 namespace training
38 {
39 
40 namespace interface1
41 {
55 template<typename algorithmFPType, Method method, CpuType cpu>
56 class BatchContainer : public TrainingContainerIface<batch>
57 {
58 public:
64  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
66  DAAL_DEPRECATED ~BatchContainer();
70  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
71 };
72 
90 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = friedman>
91 class DAAL_EXPORT Batch : public boosting::training::Batch
92 {
93 public:
94  typedef boosting::training::Batch super;
95 
96  typedef typename super::InputType InputType;
97  typedef algorithms::logitboost::interface1::Parameter ParameterType;
98  typedef algorithms::logitboost::training::interface1::Result ResultType;
99 
100  ParameterType parameter;
101  InputType input;
107  DAAL_DEPRECATED Batch(size_t nClasses)
108  {
109  initialize();
110  parameter.nClasses = nClasses;
111  }
112 
119  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) : boosting::training::Batch(other),
120  parameter(other.parameter), input(other.input)
121  {
122  initialize();
123  }
124 
125  DAAL_DEPRECATED_VIRTUAL virtual ~Batch() {}
126 
131  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
132 
137  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
138 
143  DAAL_DEPRECATED ResultPtr getResult()
144  {
145  return ResultType::cast(_result);
146  }
147 
151  DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
152  {
153  _result.reset(new ResultType());
154  DAAL_CHECK(_result, services::ErrorNullResult);
155  _res = NULL;
156  return services::Status();
157  }
158 
164  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
165  {
166  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
167  }
168 
169 protected:
170  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
171  {
172  return new Batch<algorithmFPType, method>(*this);
173  }
174 
175  services::Status allocateResult() DAAL_C11_OVERRIDE
176  {
177  ResultPtr res = getResult();
178  DAAL_CHECK(_result, services::ErrorNullResult);
179  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
180  _res = _result.get();
181  return s;
182  }
183 
184  void initialize()
185  {
186  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
187  _in = &input;
188  _par = &parameter;
189  _result.reset(new ResultType());
190  }
191 };
193 } // namespace interface1
194 
195 namespace interface2
196 {
210 template<typename algorithmFPType, Method method, CpuType cpu>
211 class BatchContainer : public TrainingContainerIface<batch>
212 {
213 public:
219  BatchContainer(daal::services::Environment::env *daalEnv);
221  ~BatchContainer();
225  services::Status compute() DAAL_C11_OVERRIDE;
226 };
244 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = friedman>
245 class DAAL_EXPORT Batch : public classifier::training::Batch
246 {
247 public:
248  typedef classifier::training::Batch super;
249 
250  typedef typename super::InputType InputType;
251  typedef algorithms::logitboost::Parameter ParameterType;
252  typedef algorithms::logitboost::training::Result ResultType;
253 
254  InputType input;
260  Batch(size_t nClasses);
261 
268  Batch(const Batch<algorithmFPType, method> &other);
269 
270  virtual ~Batch()
271  {
272  delete _par;
273  }
274 
279  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
280 
285  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
286 
291  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
292 
297  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
298 
303  ResultPtr getResult()
304  {
305  return ResultType::cast(_result);
306  }
307 
311  services::Status resetResult() DAAL_C11_OVERRIDE
312  {
313  _result.reset(new ResultType());
314  DAAL_CHECK(_result, services::ErrorNullResult);
315  _res = NULL;
316  return services::Status();
317  }
318 
324  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
325  {
326  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
327  }
328 
329 protected:
330  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
331  {
332  return new Batch<algorithmFPType, method>(*this);
333  }
334 
335  services::Status allocateResult() DAAL_C11_OVERRIDE
336  {
337  ResultPtr res = getResult();
338  DAAL_CHECK(_result, services::ErrorNullResult);
339  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
340  _res = _result.get();
341  return s;
342  }
343 
344  void initialize()
345  {
346  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
347  _in = &input;
348  _result.reset(new ResultType());
349  }
350 };
352 } // namespace interface2
353 using interface2::Batch;
354 using interface2::BatchContainer;
355 
356 } // namespace daal::algorithms::logitboost::training
357 }
358 }
359 } // namespace daal
360 #endif // __LOGIT_BOOST_TRAINING_BATCH_H__
daal::algorithms::logitboost::training::interface1::Batch::parameter
ParameterType parameter
Definition: logitboost_training_batch.h:100
daal::algorithms::logitboost::training::interface2::Batch::parameter
ParameterType & parameter()
Definition: logitboost_training_batch.h:279
daal::algorithms::logitboost::training::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::batch
Definition: daal_defines.h:112
daal::algorithms::logitboost::training::interface1::Batch::input
InputType input
Definition: logitboost_training_batch.h:101
daal::algorithms::logitboost::training::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: logitboost_training_batch.h:285
daal::algorithms::logitboost::training::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::logitboost::training::interface2::Batch
Trains model of the LogitBoost algorithms in the batch processing mode.
Definition: logitboost_training_batch.h:245
daal::algorithms::logitboost::training::interface2::Batch::input
InputType input
Definition: logitboost_training_batch.h:254
daal::algorithms::logitboost::training::interface2::BatchContainer
Provides methods to run implementations of LogitBoost model-based training. This class is associated ...
Definition: logitboost_training_batch.h:211
daal::algorithms::logitboost::training::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logitboost_training_batch.h:324
daal::algorithms::logitboost::training::interface2::Batch::getResult
ResultPtr getResult()
Definition: logitboost_training_batch.h:303
daal::algorithms::logitboost::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: logitboost_training_batch.h:119
daal::algorithms::logitboost::training::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::logitboost::training::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:131
daal::services::ErrorNullResult
Definition: error_indexes.h:98
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:56
daal::algorithms::logitboost::training::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::logitboost::training::interface1::Batch::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: logitboost_training_batch.h:143
daal::algorithms::logitboost::training::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::logitboost::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nClasses)
Definition: logitboost_training_batch.h:107
daal::algorithms::logitboost::training::interface1::Batch::resetResult
DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:151
daal::algorithms::logitboost::training::interface2::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:311
daal::algorithms::logitboost::training::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:137
daal::algorithms::logitboost::training::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:291
daal::algorithms::logitboost::training::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logitboost_training_batch.h:164
daal::algorithms::logitboost::training::interface1::Result
Provides methods to access final results obtained with the compute() method of the LogitBoost trainin...
Definition: logitboost_training_types.h:73
daal::algorithms::logitboost::training::interface1::Batch
Trains model of the LogitBoost algorithms in the batch processing mode.
Definition: logitboost_training_batch.h:91
daal::algorithms::logitboost::training::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::logitboost::interface1::Parameter
LogitBoost algorithm parameters.
Definition: logitboost_model.h:61
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::logitboost::training::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logitboost_training_batch.h:297

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