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

logitboost_predict.h
1 /* file: logitboost_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 LogitBoost model-based prediction
21 //--
22 */
23 
24 #ifndef __LOGIT_BOOST_PREDICT_H__
25 #define __LOGIT_BOOST_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/boosting/boosting_predict.h"
29 #include "algorithms/boosting/logitboost_model.h"
30 #include "algorithms/boosting/logitboost_predict_types.h"
31 #include "algorithms/classifier/classifier_predict.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace logitboost
38 {
42 namespace prediction
43 {
53 enum Method
54 {
55  defaultDense = 0
56 };
57 
61 namespace interface1
62 {
72 template<typename algorithmFPType, Method method, CpuType cpu>
73 class BatchContainer : public PredictionContainerIface
74 {
75 public:
80  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
82  DAAL_DEPRECATED ~BatchContainer();
86  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
87 };
88 
109 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
110 class DAAL_EXPORT Batch : public boosting::prediction::Batch
111 {
112 public:
113  typedef boosting::prediction::Batch super;
114 
115  typedef algorithms::logitboost::prediction::interface1::Input InputType;
116  typedef algorithms::logitboost::interface1::Parameter ParameterType;
117  typedef typename super::ResultType ResultType;
118 
119  InputType input;
120  ParameterType parameter;
126  DAAL_DEPRECATED Batch(size_t nClasses)
127  {
128  initialize();
129  parameter.nClasses = nClasses;
130  };
131 
138  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) : boosting::prediction::Batch(other),
139  input(other.input), parameter(other.parameter)
140  {
141  initialize();
142  }
143 
144  DAAL_DEPRECATED ~Batch() {}
145 
150  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
151 
156  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
157 
163  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
164  {
165  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
166  }
167 
168 protected:
169  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
170  {
171  return new Batch<algorithmFPType, method>(*this);
172  }
173 
174  services::Status allocateResult() DAAL_C11_OVERRIDE
175  {
176  services::Status s = _result->allocate<algorithmFPType>(&input, 0, 0);
177  _res = _result.get();
178  return s;
179  }
180 
181  void initialize()
182  {
183  _in = &input;
184  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
185  _par = &parameter;
186  }
187 };
189 } // namespace interface1
190 
194 namespace interface2
195 {
205 template<typename algorithmFPType, Method method, CpuType cpu>
206 class BatchContainer : public PredictionContainerIface
207 {
208 public:
213  BatchContainer(daal::services::Environment::env *daalEnv);
215  ~BatchContainer();
219  services::Status compute() DAAL_C11_OVERRIDE;
220 };
221 
242 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
243 class DAAL_EXPORT Batch : public classifier::prediction::Batch
244 {
245 public:
246  typedef classifier::prediction::Batch super;
247 
248  typedef algorithms::logitboost::prediction::Input InputType;
249  typedef algorithms::logitboost::Parameter ParameterType;
250  typedef typename super::ResultType ResultType;
251 
252  InputType input;
258  Batch(size_t nClasses);
259 
266  Batch(const Batch<algorithmFPType, method> &other);
267 
268  ~Batch()
269  {
270  delete _par;
271  }
272 
277  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
278 
283  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
284 
289  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
290 
295  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
296 
302  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
303  {
304  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
305  }
306 
307 protected:
308  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
309  {
310  return new Batch<algorithmFPType, method>(*this);
311  }
312 
313  services::Status allocateResult() DAAL_C11_OVERRIDE
314  {
315  services::Status s = _result->allocate<algorithmFPType>(&input, _par, 0);
316  _res = _result.get();
317  return s;
318  }
319 
320  void initialize()
321  {
322  _in = &input;
323  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
324  }
325 };
327 } // namespace interface2
328 using interface2::Batch;
329 using interface2::BatchContainer;
330 
331 } // namespace daal::algorithms::logitboost::prediction
332 }
333 }
334 } // namespace daal
335 #endif
daal::algorithms::logitboost::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::logitboost::prediction::interface1::Batch::input
InputType input
Definition: logitboost_predict.h:119
daal::batch
Definition: daal_defines.h:112
daal::algorithms::logitboost::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logitboost_predict.h:295
daal::algorithms::logitboost::prediction::interface2::Batch::parameter
ParameterType & parameter()
Definition: logitboost_predict.h:277
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::logitboost::prediction::interface2::Batch::input
InputType input
Definition: logitboost_predict.h:252
daal::algorithms::logitboost::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logitboost_predict.h:302
daal::algorithms::logitboost::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: logitboost_predict.h:120
daal::algorithms::logitboost::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::logitboost::prediction::Method
Method
Definition: logitboost_predict.h:53
daal::algorithms::logitboost::prediction::defaultDense
Definition: logitboost_predict.h:55
daal::algorithms::logitboost::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: logitboost_predict.h:150
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::logitboost::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: logitboost_predict.h:156
daal::algorithms::logitboost::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::logitboost::prediction::interface1::BatchContainer
Provides methods to run implementations of the LogitBoost algorithm.
Definition: logitboost_predict.h:73
daal::algorithms::logitboost::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::logitboost::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: logitboost_predict.h:138
daal::algorithms::logitboost::prediction::interface1::Input
Input objects in the prediction stage of the logitboost algorithm.
Definition: logitboost_predict_types.h:61
daal::algorithms::logitboost::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logitboost_predict.h:163
daal::algorithms::logitboost::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: logitboost_predict.h:289
daal::algorithms::logitboost::prediction::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::logitboost::prediction::interface2::Batch
Predicts LogitBoost classification results.
Definition: logitboost_predict.h:243
daal::algorithms::logitboost::prediction::interface1::Batch
Predicts LogitBoost classification results.
Definition: logitboost_predict.h:110
daal::algorithms::logitboost::interface1::Parameter
LogitBoost algorithm parameters.
Definition: logitboost_model.h:61
daal::algorithms::logitboost::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nClasses)
Definition: logitboost_predict.h:126
daal::algorithms::logitboost::prediction::interface2::BatchContainer
Provides methods to run implementations of the LogitBoost algorithm. This class is associated with da...
Definition: logitboost_predict.h:206
daal::algorithms::logitboost::prediction::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: logitboost_predict.h:283
daal::algorithms::logitboost::prediction::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()

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