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

decision_forest_classification_predict.h
1 /* file: decision_forest_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 forest classification model-based prediction
21 //--
22 */
23 
24 #ifndef __DECISION_FOREST_CLASSIFICATION_PREDICT_H__
25 #define __DECISION_FOREST_CLASSIFICATION_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/classifier/classifier_predict.h"
29 #include "algorithms/decision_forest/decision_forest_classification_model.h"
30 #include "algorithms/decision_forest/decision_forest_classification_predict_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace decision_forest
37 {
38 namespace classification
39 {
43 namespace prediction
44 {
54 enum Method
55 {
56  defaultDense = 0
57 };
58 
62 namespace interface1
63 {
73 template<typename algorithmFPType, Method method, CpuType cpu>
74 class BatchContainer : public PredictionContainerIface
75 {
76 public:
81  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
83  DAAL_DEPRECATED ~BatchContainer();
88  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
89 };
90 
111 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
112 class Batch : public classifier::prediction::interface1::Batch
113 {
114 public:
115  typedef classifier::prediction::interface1::Batch super;
116 
117  typedef algorithms::decision_forest::classification::prediction::Input InputType;
118  typedef typename super::ParameterType ParameterType;
119  typedef typename super::ResultType ResultType;
120 
121  InputType input;
122  ParameterType parameter;
128  DAAL_DEPRECATED Batch(size_t nClasses): parameter(nClasses)
129  {
130  initialize();
131  };
132 
139  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) : classifier::prediction::interface1::Batch(other),
140  input(other.input), parameter(other.parameter)
141  {
142  initialize();
143  }
144 
145  DAAL_DEPRECATED ~Batch() {}
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, 0, 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  _par = &parameter;
187  }
188 };
190 } // namespace interface1
191 
195 namespace interface2
196 {
206 template<typename algorithmFPType, Method method, CpuType cpu>
207 class BatchContainer : public PredictionContainerIface
208 {
209 public:
214  BatchContainer(daal::services::Environment::env *daalEnv);
216  ~BatchContainer();
221  services::Status compute() DAAL_C11_OVERRIDE;
222 };
223 
244 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
245 class Batch : public classifier::prediction::Batch
246 {
247 public:
248  typedef classifier::prediction::Batch super;
249 
250  typedef algorithms::decision_forest::classification::prediction::Input InputType;
251  typedef typename super::ParameterType ParameterType;
252  typedef typename super::ResultType ResultType;
253 
254  InputType input;
255  ParameterType parameter;
261  Batch(size_t nClasses): parameter(nClasses)
262  {
263  initialize();
264  };
265 
272  Batch(const Batch<algorithmFPType, method> &other) : classifier::prediction::Batch(other),
273  input(other.input), parameter(other.parameter)
274  {
275  initialize();
276  }
277 
278  ~Batch() {}
279 
284  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
285 
290  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
291 
297  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
298  {
299  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
300  }
301 
302 protected:
303  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
304  {
305  return new Batch<algorithmFPType, method>(*this);
306  }
307 
308  services::Status allocateResult() DAAL_C11_OVERRIDE
309  {
310  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, 0);
311  _res = _result.get();
312  return s;
313  }
314 
315  void initialize()
316  {
317  _in = &input;
318  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
319  _par = &parameter;
320  }
321 };
323 } // namespace interface2
324 
328 namespace interface3
329 {
340 template <typename algorithmFPType, Method method, CpuType cpu>
341 class BatchContainer : public PredictionContainerIface
342 {
343 public:
348  BatchContainer(daal::services::Environment::env * daalEnv);
350  ~BatchContainer();
355  services::Status compute() DAAL_C11_OVERRIDE;
356 };
357 
378 template <typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
379 class DAAL_EXPORT Batch : public classifier::prediction::Batch
380 {
381 public:
382  typedef classifier::prediction::Batch super;
383 
384  typedef algorithms::decision_forest::classification::prediction::Input InputType;
385  typedef algorithms::decision_forest::classification::prediction::Parameter ParameterType;
386  typedef typename super::ResultType ResultType;
387 
388  InputType input;
394  Batch(size_t nClasses);
395 
402  Batch(const Batch<algorithmFPType, method> & other);
403 
404  ~Batch() { delete _par; }
405 
410  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
411 
416  ParameterType & parameter() { return *static_cast<ParameterType *>(_par); }
417 
422  const ParameterType & parameter() const { return *static_cast<const ParameterType *>(_par); }
423 
428  virtual int getMethod() const DAAL_C11_OVERRIDE { return (int)method; }
429 
435  services::SharedPtr<Batch<algorithmFPType, method> > clone() const { return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl()); }
436 
437 protected:
438  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE { return new Batch<algorithmFPType, method>(*this); }
439 
440  services::Status allocateResult() DAAL_C11_OVERRIDE
441  {
442  services::Status s = _result->allocate<algorithmFPType>(&input, _par, 0);
443  _res = _result.get();
444  return s;
445  }
446 
447  void initialize()
448  {
449  _in = &input;
450  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
451  _result.reset(new ResultType());
452  }
453 };
455 } // namespace interface3
456 
457 using interface3::BatchContainer;
458 using interface3::Batch;
459 
460 } // namespace daal::algorithms::decision_forest::classification::prediction
461 }
462 }
463 }
464 } // namespace daal
465 #endif
daal::algorithms::decision_forest::classification::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: decision_forest_classification_predict.h:122
daal::algorithms::decision_forest::classification::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::decision_forest::classification::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_predict.h:284
daal::algorithms::decision_forest::classification::prediction::interface2::Batch
Predicts decision_forest classification results.
Definition: decision_forest_classification_predict.h:245
daal::batch
Definition: daal_defines.h:112
daal::algorithms::decision_forest::classification::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_forest_classification_predict.h:139
daal::algorithms::decision_forest::classification::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::decision_forest::classification::prediction::interface3::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::decision_forest::classification::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::decision_forest::classification::prediction::interface2::BatchContainer
Provides methods to run implementations of the decision_forest algorithm. This class is associated wi...
Definition: decision_forest_classification_predict.h:207
daal::algorithms::decision_forest::classification::prediction::interface1::BatchContainer
Provides methods to run implementations of the decision_forest algorithm.
Definition: decision_forest_classification_predict.h:74
daal::algorithms::decision_forest::classification::prediction::interface3::Batch
Predicts decision_forest classification results.
Definition: decision_forest_classification_predict.h:379
daal::algorithms::decision_forest::classification::prediction::defaultDense
Definition: decision_forest_classification_predict.h:56
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_forest::classification::prediction::interface3::BatchContainer
Provides methods to run implementations of the decision_forest algorithm. This class is associated wi...
Definition: decision_forest_classification_predict.h:341
daal::algorithms::decision_forest::classification::prediction::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: decision_forest_classification_predict.h:272
daal::algorithms::decision_forest::classification::prediction::interface1::Batch
Predicts decision_forest classification results.
Definition: decision_forest_classification_predict.h:112
daal::algorithms::decision_forest::classification::prediction::interface1::Batch::input
InputType input
Definition: decision_forest_classification_predict.h:121
daal::algorithms::decision_forest::classification::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_forest_classification_predict.h:290
daal::algorithms::decision_forest::classification::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_forest_classification_predict.h:164
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_forest::classification::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nClasses)
Definition: decision_forest_classification_predict.h:128
daal::algorithms::decision_forest::classification::prediction::interface2::Batch::input
InputType input
Definition: decision_forest_classification_predict.h:254
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_forest::classification::prediction::interface3::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::decision_forest::classification::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_forest_classification_predict.h:297
daal::algorithms::decision_forest::classification::prediction::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::decision_forest::classification::prediction::interface2::Batch::parameter
ParameterType parameter
Definition: decision_forest_classification_predict.h:255
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::decision_forest::classification::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_forest_classification_predict.h:157
daal::algorithms::decision_forest::classification::prediction::interface3::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: decision_forest_classification_predict.h:435
daal::algorithms::decision_forest::classification::prediction::interface3::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::decision_forest::classification::prediction::interface3::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_predict.h:410
daal::algorithms::decision_forest::classification::prediction::interface3::Batch::input
InputType input
Definition: decision_forest_classification_predict.h:388
daal::algorithms::decision_forest::classification::prediction::interface3::Batch::parameter
const ParameterType & parameter() const
Definition: decision_forest_classification_predict.h:422
daal::algorithms::decision_forest::classification::prediction::interface2::Batch::Batch
Batch(size_t nClasses)
Definition: decision_forest_classification_predict.h:261
daal::algorithms::decision_forest::classification::prediction::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::decision_forest::classification::prediction::Method
Method
Definition: decision_forest_classification_predict.h:54
daal::algorithms::decision_forest::classification::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::decision_forest::classification::prediction::interface3::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: decision_forest_classification_predict.h:428
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::decision_forest::classification::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: decision_forest_classification_predict.h:151
daal::algorithms::decision_forest::classification::prediction::interface3::Batch::parameter
ParameterType & parameter()
Definition: decision_forest_classification_predict.h:416

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