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

gbt_regression_predict.h
1 /* file: gbt_regression_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 model-based prediction
19 //--
20 */
21 
22 #ifndef __GBT_REGRESSION_PREDICT_H__
23 #define __GBT_REGRESSION_PREDICT_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/gradient_boosted_trees/gbt_regression_predict_types.h"
27 #include "algorithms/regression/regression_predict.h"
28 
29 namespace daal
30 {
31 namespace algorithms
32 {
33 namespace gbt
34 {
35 namespace regression
36 {
37 namespace prediction
38 {
39 namespace interface1
40 {
50 template<typename algorithmFPType, Method method, CpuType cpu>
51 class DAAL_EXPORT BatchContainer : public PredictionContainerIface
52 {
53 public:
58  BatchContainer(daal::services::Environment::env *daalEnv);
59  ~BatchContainer();
64  services::Status compute() DAAL_C11_OVERRIDE;
65 };
66 
83 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
84 class Batch : public algorithms::regression::prediction::Batch
85 {
86 public:
87  typedef algorithms::gbt::regression::prediction::Input InputType;
88  typedef algorithms::gbt::regression::prediction::Parameter ParameterType;
89  typedef algorithms::gbt::regression::prediction::Result ResultType;
90 
91  InputType input;
94  Batch()
95  {
96  _par = new ParameterType();
97  initialize();
98  }
99 
106  Batch(const Batch<algorithmFPType, method> &other) : input(other.input)
107  {
108  _par = new ParameterType(other.parameter());
109  initialize();
110  }
111 
113  ~Batch()
114  {
115  delete _par;
116  }
117 
122  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
123 
128  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
129 
134  virtual algorithms::regression::prediction::Input* getInput() DAAL_C11_OVERRIDE{ return &input; }
135 
140  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
141 
146  ResultPtr getResult() { return ResultType::cast(_result); }
147 
153  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
154  {
155  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
156  }
157 
158 protected:
159 
160  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
161  {
162  return new Batch<algorithmFPType, method>(*this);
163  }
164 
165  services::Status allocateResult() DAAL_C11_OVERRIDE
166  {
167  services::Status s = getResult()->template allocate<algorithmFPType>(_in, 0, 0);
168  _res = _result.get();
169  return s;
170  }
171 
172  void initialize()
173  {
174  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
175  _in = &input;
176  _result.reset(new ResultType());
177  }
178 };
180 } // namespace interface1
181 using interface1::BatchContainer;
182 using interface1::Batch;
183 
184 }
185 }
186 }
187 }
188 }
189 #endif
daal::algorithms::gbt::regression::prediction::interface1::Batch::Batch
Batch()
Definition: gbt_regression_predict.h:94
daal::algorithms::gbt::regression::prediction::interface1::Batch::input
InputType input
Definition: gbt_regression_predict.h:91
daal
Definition: algorithm_base_common.h:31
daal::algorithms::gbt::regression::prediction::interface1::Batch::getResult
ResultPtr getResult()
Definition: gbt_regression_predict.h:146
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::regression::prediction::interface1::Batch::parameter
ParameterType & parameter()
Definition: gbt_regression_predict.h:122
daal::algorithms::gbt::regression::prediction::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: gbt_regression_predict.h:140
daal::algorithms::gbt::regression::prediction::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: gbt_regression_predict.h:106
daal::algorithms::gbt::regression::prediction::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: gbt_regression_predict.h:153
daal::batch
Definition: daal_defines.h:106
daal::algorithms::gbt::regression::prediction::interface1::Batch::getInput
virtual algorithms::regression::prediction::Input * getInput() DAAL_C11_OVERRIDE
Definition: gbt_regression_predict.h:134
daal::algorithms::gbt::regression::prediction::interface1::Batch::~Batch
~Batch()
Definition: gbt_regression_predict.h:113
daal::algorithms::gbt::regression::prediction::interface1::Batch
Provides methods to run implementations of the model-based prediction.
Definition: gbt_regression_predict.h:84
daal::algorithms::gbt::regression::prediction::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: gbt_regression_predict.h:128
daal::algorithms::classifier::prediction::prediction
Definition: classifier_predict_types.h:76
daal::algorithms::gbt::regression::prediction::interface1::BatchContainer
Class containing computation methods for model-based prediction.
Definition: gbt_regression_predict.h:51

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