C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 3

gbt_classification_predict.h
1 /* file: gbt_classification_predict.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for gradient boosted trees classification model-based prediction
19 //--
20 */
21 
22 #ifndef __GBT_CLASSIFICATION_PREDICT_H__
23 #define __GBT_CLASSIFICATION_PREDICT_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/classifier/classifier_predict.h"
27 #include "algorithms/gradient_boosted_trees/gbt_classification_model.h"
28 #include "algorithms/gradient_boosted_trees/gbt_classification_predict_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace gbt
35 {
36 namespace classification
37 {
41 namespace prediction
42 {
52 namespace interface1
53 {
63 template<typename algorithmFPType, Method method, CpuType cpu>
64 class DAAL_EXPORT BatchContainer : public PredictionContainerIface
65 {
66 public:
71  BatchContainer(daal::services::Environment::env *daalEnv);
73  ~BatchContainer();
78  services::Status compute() DAAL_C11_OVERRIDE;
79 };
80 
101 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
102 class Batch : public classifier::prediction::Batch
103 {
104 public:
105  typedef classifier::prediction::Batch super;
106 
107  typedef algorithms::gbt::classification::prediction::Input InputType;
108  typedef algorithms::gbt::classification::prediction::Parameter ParameterType;
109  typedef typename super::ResultType ResultType;
110 
111  InputType input;
117  Batch(size_t nClasses)
118  {
119  _par = new ParameterType(nClasses);
120  initialize();
121  };
122 
129  Batch(const Batch<algorithmFPType, method> &other) : classifier::prediction::Batch(other), input(other.input)
130  {
131  _par = new ParameterType(other.parameter());
132  initialize();
133  }
134 
136  ~Batch()
137  {
138  delete _par;
139  }
140 
145  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
146 
151  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
152 
157  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
158 
163  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
164 
170  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
171  {
172  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
173  }
174 
175 protected:
176  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
177  {
178  return new Batch<algorithmFPType, method>(*this);
179  }
180 
181  services::Status allocateResult() DAAL_C11_OVERRIDE
182  {
183  services::Status s = _result->allocate<algorithmFPType>(&input, 0, 0);
184  _res = _result.get();
185  return s;
186  }
187 
188  void initialize()
189  {
190  _in = &input;
191  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
192  }
193 };
195 } // namespace interface1
196 using interface1::BatchContainer;
197 using interface1::Batch;
198 
199 } // namespace daal::algorithms::gbt::classification::prediction
200 }
201 }
202 }
203 } // namespace daal
204 #endif
daal
Definition: algorithm_base_common.h:31
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:40
daal::algorithms::gbt::classification::prediction::interface1::Batch::~Batch
~Batch()
Definition: gbt_classification_predict.h:136
daal::algorithms::gbt::classification::prediction::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: gbt_classification_predict.h:129
daal::batch
Definition: daal_defines.h:106
daal::algorithms::gbt::classification::prediction::interface1::Batch::parameter
ParameterType & parameter()
Definition: gbt_classification_predict.h:145
daal::algorithms::gbt::classification::prediction::interface1::BatchContainer
Provides methods to run implementations of the gradient boosted trees algorithm. This class is associ...
Definition: gbt_classification_predict.h:64
daal::algorithms::gbt::classification::prediction::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: gbt_classification_predict.h:170
daal::algorithms::classifier::prediction::prediction
Definition: classifier_predict_types.h:76
daal::algorithms::gbt::classification::prediction::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: gbt_classification_predict.h:151
daal::algorithms::gbt::classification::prediction::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: gbt_classification_predict.h:157
daal::algorithms::gbt::classification::prediction::interface1::Batch::input
InputType input
Definition: gbt_classification_predict.h:111
daal::algorithms::gbt::classification::prediction::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: gbt_classification_predict.h:163
daal::algorithms::gbt::classification::prediction::interface1::Batch
Predicts gradient boosted trees classification results.
Definition: gbt_classification_predict.h:102
daal::algorithms::gbt::classification::prediction::interface1::Batch::Batch
Batch(size_t nClasses)
Definition: gbt_classification_predict.h:117

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