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

adaboost_predict.h
1 /* file: adaboost_predict.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 AdaBoost model-based prediction
21 //--
22 */
23 
24 #ifndef __ADA_BOOST_PREDICT_H__
25 #define __ADA_BOOST_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/boosting/boosting_predict.h"
29 #include "algorithms/boosting/adaboost_model.h"
30 #include "algorithms/boosting/adaboost_predict_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace adaboost
37 {
41 namespace prediction
42 {
52 enum Method
53 {
54  defaultDense = 0,
55  samme = defaultDense,
56  sammeR = 1
57 };
58 
62 namespace interface1
63 {
73 template<typename algorithmFPType, Method method, CpuType cpu>
74 class BatchContainer : public PredictionContainerIface
75 {
76 public:
81  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
83  DAAL_DEPRECATED~BatchContainer();
87  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
88 };
89 
110 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
111 class DAAL_EXPORT Batch : public boosting::prediction::Batch
112 {
113 public:
114  typedef boosting::prediction::Batch super;
115 
116  typedef algorithms::adaboost::prediction::interface1::Input InputType;
117  typedef algorithms::adaboost::interface1::Parameter ParameterType;
118  typedef typename super::ResultType ResultType;
119 
120  InputType input;
121  ParameterType parameter;
123  DAAL_DEPRECATED Batch()
124  {
125  initialize();
126  }
127 
134  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) : boosting::prediction::Batch(other),
135  input(other.input), parameter(other.parameter)
136  {
137  initialize();
138  }
139 
140  DAAL_DEPRECATED ~Batch() {}
141 
146  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
147 
152  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
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  services::Status s = _result->allocate<algorithmFPType>(&input, 0, 0);
173  _res = _result.get();
174  return s;
175  }
176 
177  void initialize()
178  {
179  _in = &input;
180  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
181  _par = &parameter;
182  }
183 };
184 } // namespace interface1
185 
189 namespace interface2
190 {
200 template<typename algorithmFPType, Method method, CpuType cpu>
201 class BatchContainer : public PredictionContainerIface
202 {
203 public:
208  BatchContainer(daal::services::Environment::env *daalEnv);
210  ~BatchContainer();
214  services::Status compute() DAAL_C11_OVERRIDE;
215 };
236 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
237 class DAAL_EXPORT Batch : public classifier::prediction::Batch
238 {
239 public:
240  typedef classifier::prediction::Batch super;
241 
242  typedef algorithms::adaboost::prediction::Input InputType;
243  typedef algorithms::adaboost::Parameter ParameterType;
244  typedef typename super::ResultType ResultType;
245 
246  InputType input;
252  Batch(size_t nClasses);
253 
260  Batch(const Batch<algorithmFPType, method> &other);
261 
262  ~Batch()
263  {
264  delete _par;
265  }
266 
271  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
272 
277  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
278 
283  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
284 
289  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
290 
296  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
297  {
298  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
299  }
300 
301 protected:
302  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
303  {
304  return new Batch<algorithmFPType, method>(*this);
305  }
306 
307  services::Status allocateResult() DAAL_C11_OVERRIDE
308  {
309  services::Status s = _result->allocate<algorithmFPType>(&input, _par, 0);
310  _res = _result.get();
311  return s;
312  }
313 
314  void initialize()
315  {
316  _in = &input;
317  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
318  }
319 };
320 } // namespace interface2
321 using interface2::Batch;
322 using interface2::BatchContainer;
323 
325 } // namespace daal::algorithms::adaboost::prediction
326 }
327 }
328 } // namespace daal
329 #endif
daal::algorithms::adaboost::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::adaboost::prediction::interface2::Batch
Predict AdaBoost classification results.
Definition: adaboost_predict.h:237
daal::batch
Definition: daal_defines.h:112
daal::algorithms::adaboost::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: adaboost_predict.h:134
daal::algorithms::adaboost::prediction::interface1::BatchContainer
Provides methods to run implementations of the AdaBoost algorithm.
Definition: adaboost_predict.h:74
daal::algorithms::adaboost::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: adaboost_predict.h:121
daal::algorithms::adaboost::prediction::sammeR
Definition: adaboost_predict.h:56
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::adaboost::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::adaboost::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::adaboost::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: adaboost_predict.h:146
daal::algorithms::adaboost::prediction::defaultDense
Definition: adaboost_predict.h:54
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::adaboost::interface1::Parameter
AdaBoost algorithm parameters.
Definition: adaboost_model.h:59
daal::algorithms::adaboost::prediction::interface2::BatchContainer
Provides methods to run implementations of the AdaBoost algorithm. It is associated with daal::algori...
Definition: adaboost_predict.h:201
daal::algorithms::adaboost::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::adaboost::prediction::interface2::Batch::parameter
ParameterType & parameter()
Definition: adaboost_predict.h:271
daal::algorithms::adaboost::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: adaboost_predict.h:289
daal::algorithms::adaboost::prediction::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::adaboost::prediction::interface1::Input
Input objects in the prediction stage of the adaboost algorithm.
Definition: adaboost_predict_types.h:53
daal::algorithms::adaboost::prediction::interface2::Batch::input
InputType input
Definition: adaboost_predict.h:246
daal::algorithms::adaboost::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: adaboost_predict.h:152
daal::algorithms::adaboost::prediction::samme
Definition: adaboost_predict.h:55
daal::algorithms::adaboost::prediction::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::adaboost::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: adaboost_predict.h:283
daal::algorithms::adaboost::prediction::Method
Method
Definition: adaboost_predict.h:52
daal::algorithms::adaboost::prediction::interface1::Batch
Predict AdaBoost classification results.
Definition: adaboost_predict.h:111
daal::algorithms::adaboost::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: adaboost_predict.h:296
daal::algorithms::adaboost::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: adaboost_predict.h:159
daal::algorithms::adaboost::prediction::interface1::Batch::input
InputType input
Definition: adaboost_predict.h:120
daal::algorithms::adaboost::prediction::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: adaboost_predict.h:277

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