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

gbt_classification_predict.h
1 /* file: gbt_classification_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 gradient boosted trees classification model-based prediction
21 //--
22 */
23 
24 #ifndef __GBT_CLASSIFICATION_PREDICT_H__
25 #define __GBT_CLASSIFICATION_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/classifier/classifier_predict.h"
29 #include "algorithms/gradient_boosted_trees/gbt_classification_model.h"
30 #include "algorithms/gradient_boosted_trees/gbt_classification_predict_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace gbt
37 {
38 namespace classification
39 {
43 namespace prediction
44 {
54 namespace interface1
55 {
65 template<typename algorithmFPType, Method method, CpuType cpu>
66 class BatchContainer : public PredictionContainerIface
67 {
68 public:
73  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
75  DAAL_DEPRECATED ~BatchContainer();
80  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
81 };
82 
103 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
104 class DAAL_EXPORT Batch : public classifier::prediction::interface1::Batch
105 {
106 public:
107  typedef classifier::prediction::interface1::Batch super;
108 
109  typedef algorithms::gbt::classification::prediction::Input InputType;
110  typedef algorithms::gbt::classification::prediction::interface1::Parameter ParameterType;
111  typedef typename super::ResultType ResultType;
112 
113  InputType input;
119  DAAL_DEPRECATED Batch(size_t nClasses);
120 
127  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other);
128 
130  DAAL_DEPRECATED ~Batch()
131  {
132  delete _par;
133  }
134 
139  DAAL_DEPRECATED ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
140 
145  DAAL_DEPRECATED const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
146 
151  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
152 
157  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
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  services::Status s = _result->allocate<algorithmFPType>(&input, _par, 0);
178  _res = _result.get();
179  return s;
180  }
181 
182  void initialize()
183  {
184  _in = &input;
185  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
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();
220  services::Status compute() DAAL_C11_OVERRIDE;
221 };
222 
243 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
244 class DAAL_EXPORT Batch : public classifier::prediction::Batch
245 {
246 public:
247  typedef classifier::prediction::Batch super;
248 
249  typedef algorithms::gbt::classification::prediction::Input InputType;
250  typedef algorithms::gbt::classification::prediction::Parameter ParameterType;
251  typedef typename super::ResultType ResultType;
252 
253  InputType input;
259  Batch(size_t nClasses);
260 
267  Batch(const Batch<algorithmFPType, method> &other);
268 
270  ~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 
304  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
305  {
306  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
307  }
308 
309 protected:
310  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
311  {
312  return new Batch<algorithmFPType, method>(*this);
313  }
314 
315  services::Status allocateResult() DAAL_C11_OVERRIDE
316  {
317  services::Status s = _result->allocate<algorithmFPType>(&input, _par, 0);
318  _res = _result.get();
319  return s;
320  }
321 
322  void initialize()
323  {
324  _in = &input;
325  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
326  }
327 };
329 } // namespace interface1
330 using interface2::BatchContainer;
331 using interface2::Batch;
332 
333 } // namespace daal::algorithms::gbt::classification::prediction
334 }
335 }
336 }
337 } // namespace daal
338 #endif
daal::algorithms::gbt::classification::prediction::interface1::BatchContainer
Provides methods to run implementations of the gradient boosted trees algorithm.
Definition: gbt_classification_predict.h:66
daal::algorithms::gbt::classification::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::gbt::classification::prediction::interface1::Batch::input
InputType input
Definition: gbt_classification_predict.h:113
daal::algorithms::gbt::classification::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: gbt_classification_predict.h:291
daal::algorithms::gbt::classification::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: gbt_classification_predict.h:304
daal::batch
Definition: daal_defines.h:112
daal::algorithms::gbt::classification::prediction::interface2::Batch::~Batch
~Batch()
Definition: gbt_classification_predict.h:270
daal::algorithms::gbt::classification::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::gbt::classification::prediction::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::gbt::classification::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: gbt_classification_predict.h:297
daal::algorithms::gbt::classification::prediction::interface1::Batch::parameter
DAAL_DEPRECATED const ParameterType & parameter() const
Definition: gbt_classification_predict.h:145
daal::algorithms::gbt::classification::prediction::interface1::Batch::~Batch
DAAL_DEPRECATED ~Batch()
Definition: gbt_classification_predict.h:130
daal::algorithms::classifier::prediction::interface1::Input
Input objects in the prediction stage of the classification algorithm.
Definition: classifier_predict_types.h:111
daal::algorithms::gbt::classification::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::gbt::classification::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: gbt_classification_predict.h:157
daal::algorithms::gbt::classification::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: gbt_classification_predict.h:151
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::gbt::classification::prediction::interface2::Batch
Predicts gradient boosted trees classification results.
Definition: gbt_classification_predict.h:244
daal::algorithms::classifier::prediction::interface1::Result
Provides methods to access prediction results obtained with the compute() method of the classifier pr...
Definition: classifier_predict_types.h:168
daal::algorithms::gbt::classification::prediction::interface2::Batch::parameter
ParameterType & parameter()
Definition: gbt_classification_predict.h:279
daal::algorithms::gbt::classification::prediction::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: gbt_classification_predict.h:285
daal::algorithms::gbt::classification::prediction::interface2::BatchContainer
Provides methods to run implementations of the gradient boosted trees algorithm. This class is associ...
Definition: gbt_classification_predict.h:206
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::gbt::classification::prediction::interface1::Parameter
Parameters of the prediction algorithm.
Definition: gbt_classification_predict_types.h:73
daal::algorithms::gbt::classification::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: gbt_classification_predict.h:164
daal::algorithms::gbt::classification::prediction::interface1::Batch::parameter
DAAL_DEPRECATED ParameterType & parameter()
Definition: gbt_classification_predict.h:139
daal::algorithms::gbt::classification::prediction::interface1::Batch
Predicts gradient boosted trees classification results.
Definition: gbt_classification_predict.h:104
daal::algorithms::gbt::classification::prediction::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::gbt::classification::prediction::interface2::Batch::input
InputType input
Definition: gbt_classification_predict.h:253
daal::algorithms::classifier::prediction::interface1::Batch
Base class for making predictions based on the model of the classification algorithms.
Definition: classifier_predict.h:61
daal::algorithms::gbt::classification::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE

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