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

brownboost_training_batch.h
1 /* file: brownboost_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 BrownBoost model-based training
21 //--
22 */
23 
24 #ifndef __BROWN_BOOST_TRAINING_BATCH_H__
25 #define __BROWN_BOOST_TRAINING_BATCH_H__
26 
27 #include "algorithms/boosting/boosting_training_batch.h"
28 #include "algorithms/boosting/brownboost_training_types.h"
29 #include "algorithms/classifier/classifier_training_batch.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace brownboost
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 = defaultDense>
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::brownboost::interface1::Parameter ParameterType;
98  typedef algorithms::brownboost::training::interface1::Result ResultType;
99 
100  ParameterType parameter;
101  InputType input;
103  DAAL_DEPRECATED Batch()
104  {
105  initialize();
106  }
107 
114  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) : boosting::training::Batch(other),
115  parameter(other.parameter), input(other.input)
116  {
117  initialize();
118  }
119 
120  DAAL_DEPRECATED_VIRTUAL virtual ~Batch() {}
121 
126  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
127 
132  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
133 
138  DAAL_DEPRECATED ResultPtr getResult()
139  {
140  return ResultType::cast(_result);
141  }
142 
146  DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
147  {
148  _result.reset(new ResultType());
149  DAAL_CHECK(_result, services::ErrorNullResult);
150  _res = NULL;
151  return services::Status();
152  }
153 
159  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
160  {
161  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
162  }
163 
164 protected:
165  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
166  {
167  return new Batch<algorithmFPType, method>(*this);
168  }
169 
170  services::Status allocateResult() DAAL_C11_OVERRIDE
171  {
172  ResultPtr res = getResult();
173  DAAL_CHECK(_result, services::ErrorNullResult);
174  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
175  _res = _result.get();
176  return s;
177  }
178 
179  void initialize()
180  {
181  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
182  _in = &input;
183  _par = &parameter;
184  _result.reset(new ResultType());
185  }
186 };
188 } // namespace interface1
189 
190 namespace interface2
191 {
205 template<typename algorithmFPType, Method method, CpuType cpu>
206 class BatchContainer : public TrainingContainerIface<batch>
207 {
208 public:
214  BatchContainer(daal::services::Environment::env *daalEnv);
216  ~BatchContainer();
220  services::Status compute() DAAL_C11_OVERRIDE;
221 };
239 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
240 class DAAL_EXPORT Batch : public classifier::training::Batch
241 {
242 public:
243  typedef classifier::training::Batch super;
244 
245  typedef typename super::InputType InputType;
246  typedef algorithms::brownboost::Parameter ParameterType;
247  typedef algorithms::brownboost::training::Result ResultType;
248 
249  InputType input;
251  Batch();
252 
259  Batch(const Batch<algorithmFPType, method> &other);
260 
261  virtual ~Batch()
262  {
263  delete _par;
264  }
265 
270  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
271 
276  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
277 
282  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
283 
288  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
289 
294  ResultPtr getResult()
295  {
296  return ResultType::cast(_result);
297  }
298 
302  services::Status resetResult() DAAL_C11_OVERRIDE
303  {
304  _result.reset(new ResultType());
305  DAAL_CHECK(_result, services::ErrorNullResult);
306  _res = NULL;
307  return services::Status();
308  }
309 
315  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
316  {
317  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
318  }
319 
320 protected:
321  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
322  {
323  return new Batch<algorithmFPType, method>(*this);
324  }
325 
326  services::Status allocateResult() DAAL_C11_OVERRIDE
327  {
328  ResultPtr res = getResult();
329  DAAL_CHECK(_result, services::ErrorNullResult);
330  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
331  _res = _result.get();
332  return s;
333  }
334 
335  void initialize()
336  {
337  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
338  _in = &input;
339  _result.reset(new ResultType());
340  }
341 };
343 } // namespace interface2
344 using interface2::Batch;
345 using interface2::BatchContainer;
346 
347 } // namespace daal::algorithms::brownboost::training
348 }
349 }
350 } // namespace daal
351 #endif // __BROWN_BOOST_TRAINING_BATCH_H__
daal::algorithms::brownboost::training::interface2::Batch::input
InputType input
Definition: brownboost_training_batch.h:249
daal::algorithms::brownboost::training::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::brownboost::training::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: brownboost_training_batch.h:159
daal::algorithms::brownboost::interface1::Parameter
BrownBoost algorithm parameters.
Definition: brownboost_model.h:60
daal::algorithms::brownboost::training::interface2::BatchContainer
Provides methods to run implementations of BrownBoost model-based training. This class is associated ...
Definition: brownboost_training_batch.h:206
daal::batch
Definition: daal_defines.h:112
daal::algorithms::brownboost::training::interface2::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: brownboost_training_batch.h:302
daal::algorithms::brownboost::training::interface1::Batch::input
InputType input
Definition: brownboost_training_batch.h:101
daal::algorithms::brownboost::training::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: brownboost_training_batch.h:315
daal::algorithms::brownboost::training::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::brownboost::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: brownboost_training_batch.h:114
daal::algorithms::brownboost::training::interface1::Batch::parameter
ParameterType parameter
Definition: brownboost_training_batch.h:100
daal::algorithms::brownboost::training::interface1::Batch
Trains model of the BrownBoost algorithms in the batch processing mode.
Definition: brownboost_training_batch.h:91
daal::algorithms::brownboost::training::interface1::BatchContainer
Provides methods to run implementations of BrownBoost model-based training. This class is associated ...
Definition: brownboost_training_batch.h:56
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::brownboost::training::interface2::Batch
Trains model of the BrownBoost algorithms in the batch processing mode.
Definition: brownboost_training_batch.h:240
daal::algorithms::brownboost::training::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: brownboost_training_batch.h:288
daal::algorithms::brownboost::training::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: brownboost_training_batch.h:282
daal::algorithms::brownboost::training::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::brownboost::training::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: brownboost_training_batch.h:276
daal::algorithms::brownboost::training::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: brownboost_training_batch.h:126
daal::algorithms::brownboost::training::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::brownboost::training::interface2::Batch::parameter
ParameterType & parameter()
Definition: brownboost_training_batch.h:270
daal::algorithms::brownboost::training::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::brownboost::training::interface2::Batch::getResult
ResultPtr getResult()
Definition: brownboost_training_batch.h:294
daal::algorithms::brownboost::training::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::brownboost::training::interface1::Batch::resetResult
DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
Definition: brownboost_training_batch.h:146
daal::algorithms::brownboost::training::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: brownboost_training_batch.h:132
daal::algorithms::brownboost::training::interface1::Batch::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: brownboost_training_batch.h:138
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::brownboost::training::interface1::Result
Provides methods to access final results obtained with the compute() method.
Definition: brownboost_training_types.h:72

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