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

brownboost_predict.h
1 /* file: brownboost_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 BrownBoost model-based prediction
21 //--
22 */
23 
24 #ifndef __BROWN_BOOST_PREDICT_H__
25 #define __BROWN_BOOST_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/boosting/boosting_predict.h"
29 #include "algorithms/boosting/brownboost_model.h"
30 #include "algorithms/boosting/brownboost_predict_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace brownboost
37 {
41 namespace prediction
42 {
52 enum Method
53 {
54  defaultDense = 0
55 };
56 
60 namespace interface1
61 {
70 template<typename algorithmFPType, Method method, CpuType cpu>
71 class BatchContainer : public PredictionContainerIface
72 {
73 public:
78  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
80  DAAL_DEPRECATED ~BatchContainer();
84  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
85 };
86 
106 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
107 class DAAL_EXPORT Batch : public boosting::prediction::Batch
108 {
109 public:
110  typedef boosting::prediction::Batch super;
111 
112  typedef algorithms::brownboost::prediction::interface1::Input InputType;
113  typedef algorithms::brownboost::interface1::Parameter ParameterType;
114  typedef typename super::ResultType ResultType;
115 
116  InputType input;
117  ParameterType parameter;
119  DAAL_DEPRECATED Batch()
120  {
121  initialize();
122  }
123 
130  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) : boosting::prediction::Batch(other),
131  input(other.input), parameter(other.parameter)
132  {
133  initialize();
134  }
135 
136  DAAL_DEPRECATED ~Batch() {}
137 
142  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
143 
148  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
149 
155  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
156  {
157  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
158  }
159 
160 protected:
161  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
162  {
163  return new Batch<algorithmFPType, method>(*this);
164  }
165 
166  services::Status allocateResult() DAAL_C11_OVERRIDE
167  {
168  services::Status s = _result->allocate<algorithmFPType>(&input, 0, 0);
169  _res = _result.get();
170  return s;
171  }
172 
173  void initialize()
174  {
175  _in = &input;
176  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
177  _par = &parameter;
178  }
179 };
180 } // namespace interface1
181 
185 namespace interface2
186 {
195 template<typename algorithmFPType, Method method, CpuType cpu>
196 class BatchContainer : public PredictionContainerIface
197 {
198 public:
203  BatchContainer(daal::services::Environment::env *daalEnv);
205  ~BatchContainer();
209  services::Status compute() DAAL_C11_OVERRIDE;
210 };
230 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
231 class DAAL_EXPORT Batch : public classifier::prediction::Batch
232 {
233 public:
234  typedef classifier::prediction::Batch super;
235 
236  typedef algorithms::brownboost::prediction::Input InputType;
237  typedef algorithms::brownboost::Parameter ParameterType;
238  typedef typename super::ResultType ResultType;
239 
240  InputType input;
242  Batch();
243 
250  Batch(const Batch<algorithmFPType, method> &other);
251 
252  ~Batch()
253  {
254  delete _par;
255  }
256 
261  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
262 
267  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
268 
273  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
274 
279  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
280 
286  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
287  {
288  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
289  }
290 
291 protected:
292  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
293  {
294  return new Batch<algorithmFPType, method>(*this);
295  }
296 
297  services::Status allocateResult() DAAL_C11_OVERRIDE
298  {
299  services::Status s = _result->allocate<algorithmFPType>(&input, _par, 0);
300  _res = _result.get();
301  return s;
302  }
303 
304  void initialize()
305  {
306  _in = &input;
307  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
308  }
309 };
310 } // namespace interface2
311 using interface2::Batch;
312 using interface2::BatchContainer;
313 
315 } // namespace daal::algorithms::brownboost::prediction
316 }
317 }
318 } // namespace daal
319 #endif
daal::algorithms::brownboost::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: brownboost_predict.h:130
daal::algorithms::brownboost::interface1::Parameter
BrownBoost algorithm parameters.
Definition: brownboost_model.h:60
daal::batch
Definition: daal_defines.h:112
daal::algorithms::brownboost::prediction::interface1::Input
Input objects in the prediction stage of the brownboost algorithm.
Definition: brownboost_predict_types.h:60
daal::algorithms::brownboost::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: brownboost_predict.h:142
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::brownboost::prediction::interface2::Batch
Predicts BrownBoost classification results.
Definition: brownboost_predict.h:231
daal::algorithms::brownboost::prediction::Method
Method
Definition: brownboost_predict.h:52
daal::algorithms::brownboost::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::brownboost::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: brownboost_predict.h:279
daal::algorithms::brownboost::prediction::defaultDense
Definition: brownboost_predict.h:54
daal::algorithms::brownboost::prediction::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: brownboost_predict.h:267
daal::algorithms::brownboost::prediction::interface2::Batch::parameter
ParameterType & parameter()
Definition: brownboost_predict.h:261
daal::algorithms::brownboost::prediction::interface2::Batch::input
InputType input
Definition: brownboost_predict.h:240
daal::algorithms::brownboost::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: brownboost_predict.h:117
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::brownboost::prediction::interface2::BatchContainer
Provides methods to run implementations of the BrownBoost algorithm. This class is associated with da...
Definition: brownboost_predict.h:196
daal::algorithms::brownboost::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: brownboost_predict.h:148
daal::algorithms::brownboost::prediction::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::brownboost::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: brownboost_predict.h:286
daal::algorithms::brownboost::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::brownboost::prediction::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::brownboost::prediction::interface1::Batch
Predicts BrownBoost classification results.
Definition: brownboost_predict.h:107
daal::algorithms::brownboost::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::brownboost::prediction::interface1::BatchContainer
Provides methods to run implementations of the BrownBoost algorithm.
Definition: brownboost_predict.h:71
daal::algorithms::brownboost::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::brownboost::prediction::interface1::Batch::input
InputType input
Definition: brownboost_predict.h:116
daal::algorithms::brownboost::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: brownboost_predict.h:273
daal::algorithms::brownboost::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: brownboost_predict.h:155

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