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

decision_tree_classification_predict.h
1 /* file: decision_tree_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 Decision tree classification model-based prediction
21 //--
22 */
23 
24 #ifndef __DECISION_TREE_CLASSIFICATION_PREDICT_H__
25 #define __DECISION_TREE_CLASSIFICATION_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/decision_tree/decision_tree_classification_predict_types.h"
29 #include "algorithms/decision_tree/decision_tree_classification_model.h"
30 #include "algorithms/classifier/classifier_predict.h"
31 #include "data_management/data/homogen_numeric_table.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace decision_tree
38 {
39 namespace classification
40 {
41 namespace prediction
42 {
43 namespace interface1
44 {
55 template<typename algorithmFPType, Method method, CpuType cpu>
56 class BatchContainer : public PredictionContainerIface
57 {
58 public:
63  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
64 
65  DAAL_DEPRECATED ~BatchContainer();
66 
70  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
71 };
72 
89 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
90 class Batch : public classifier::prediction::interface1::Batch
91 {
92 public:
93  typedef classifier::prediction::interface1::Batch super;
94 
95  typedef algorithms::decision_tree::classification::prediction::Input InputType;
96  typedef algorithms::decision_tree::classification::interface1::Parameter ParameterType;
97  typedef typename super::ResultType ResultType;
98 
99  InputType input;
100  ParameterType parameter;
103  DAAL_DEPRECATED Batch() : classifier::prediction::interface1::Batch(), input(), parameter()
104  {
105  initialize();
106  }
107 
114  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> & other) : classifier::prediction::interface1::Batch(other), input(other.input), parameter(other.parameter)
115  {
116  initialize();
117  }
118 
123  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
124 
129  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
130 
136  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
137  {
138  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
139  }
140 
141 protected:
142  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
143  {
144  return new Batch<algorithmFPType, method>(*this);
145  }
146 
147  services::Status allocateResult() DAAL_C11_OVERRIDE
148  {
149  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
150  _res = _result.get();
151  return s;
152  }
153 
154  void initialize()
155  {
156  _in = &input;
157  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
158  _par = &parameter;
159  }
160 };
161 
163 } // namespace interface1
164 
165 namespace interface2
166 {
177 template<typename algorithmFPType, Method method, CpuType cpu>
178 class BatchContainer : public PredictionContainerIface
179 {
180 public:
185  BatchContainer(daal::services::Environment::env *daalEnv);
186 
187  ~BatchContainer();
188 
192  services::Status compute() DAAL_C11_OVERRIDE;
193 };
194 
211 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
212 class Batch : public classifier::prediction::Batch
213 {
214 public:
215  typedef classifier::prediction::Batch super;
216 
217  typedef algorithms::decision_tree::classification::prediction::Input InputType;
218  typedef algorithms::decision_tree::classification::Parameter ParameterType;
219  typedef typename super::ResultType ResultType;
220 
221  InputType input;
222  ParameterType parameter;
225  Batch(size_t nClasses = 2) : classifier::prediction::Batch(), input(), parameter(nClasses)
226  {
227  initialize();
228  }
229 
236  Batch(const Batch<algorithmFPType, method> & other) : classifier::prediction::Batch(other), input(other.input), parameter(other.parameter)
237  {
238  initialize();
239  }
240 
245  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
246 
251  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
252 
258  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
259  {
260  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
261  }
262 
263 protected:
264  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
265  {
266  return new Batch<algorithmFPType, method>(*this);
267  }
268 
269  services::Status allocateResult() DAAL_C11_OVERRIDE
270  {
271  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
272  _res = _result.get();
273  return s;
274  }
275 
276  void initialize()
277  {
278  _in = &input;
279  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
280  _par = &parameter;
281  }
282 };
283 
285 }
286 
287 using interface2::BatchContainer;
288 using interface2::Batch;
289 
290 } // namespace prediction
291 } // namespace classification
292 } // namespace decision_tree
293 } // namespace algorithms
294 } // namespace daal
295 
296 #endif
daal::algorithms::decision_tree::classification::prediction::interface2::Batch::parameter
ParameterType parameter
Definition: decision_tree_classification_predict.h:222
daal::algorithms::decision_tree::classification::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_tree_classification_predict.h:251
daal::batch
Definition: daal_defines.h:112
daal::algorithms::decision_tree::classification::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_tree_classification_predict.h:114
daal::algorithms::decision_tree::classification::prediction::interface2::BatchContainer
Class containing computation methods for Decision tree model-based prediction.
Definition: decision_tree_classification_predict.h:178
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::decision_tree::classification::prediction::interface2::Batch
Provides methods to run implementations of the Decision tree model-based prediction.
Definition: decision_tree_classification_predict.h:212
daal::algorithms::decision_tree::classification::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::decision_tree::classification::prediction::interface2::Batch::input
InputType input
Definition: decision_tree_classification_predict.h:221
daal::algorithms::decision_tree::classification::interface1::Parameter
Decision tree algorithm parameters.
Definition: decision_tree_classification_model.h:84
daal::algorithms::decision_tree::classification::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::decision_tree::classification::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::classifier::prediction::interface1::Input
Input objects in the prediction stage of the classification algorithm.
Definition: classifier_predict_types.h:111
daal::algorithms::decision_tree::classification::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: decision_tree_classification_predict.h:103
daal::algorithms::decision_tree::classification::prediction::interface1::Batch::input
InputType input
Definition: decision_tree_classification_predict.h:99
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::decision_tree::classification::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_tree_classification_predict.h:123
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::decision_tree::classification::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::decision_tree::classification::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_tree_classification_predict.h:136
daal::algorithms::decision_tree::classification::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_tree_classification_predict.h:258
daal::algorithms::decision_tree::classification::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: decision_tree_classification_predict.h:100
daal::algorithms::decision_tree::classification::prediction::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_tree_classification_predict.h:236
daal::algorithms::decision_tree::classification::prediction::interface2::Batch::Batch
Batch(size_t nClasses=2)
Definition: decision_tree_classification_predict.h:225
daal::algorithms::decision_tree::classification::prediction::interface1::Batch
Provides methods to run implementations of the Decision tree model-based prediction.
Definition: decision_tree_classification_predict.h:90
daal::algorithms::decision_tree::classification::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_tree_classification_predict.h:245
daal::algorithms::decision_tree::classification::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_tree_classification_predict.h:129
daal::algorithms::decision_tree::classification::prediction::interface1::BatchContainer
Class containing computation methods for Decision tree model-based prediction.
Definition: decision_tree_classification_predict.h:56
daal::algorithms::classifier::prediction::interface1::Batch
Base class for making predictions based on the model of the classification algorithms.
Definition: classifier_predict.h:61

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