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

stump_classification_predict.h
1 /* file: stump_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 stump model-based prediction
21 //--
22 */
23 
24 #ifndef __STUMP_CLASSIFICATION_PREDICT_H__
25 #define __STUMP_CLASSIFICATION_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/classifier/classifier_predict.h"
29 #include "algorithms/stump/stump_classification_predict_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace stump
36 {
37 namespace classification
38 {
47 namespace prediction
48 {
53 enum Method
54 {
55  defaultDense = 0
56 };
57 
61 namespace interface1
62 {
72 template<typename algorithmFPType, Method method, CpuType cpu>
73 class BatchContainer : public PredictionContainerIface
74 {
75 public:
80  BatchContainer(daal::services::Environment::env *daalEnv);
82  ~BatchContainer();
86  services::Status compute() DAAL_C11_OVERRIDE;
87 };
88 
109 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
110 class DAAL_EXPORT Batch : public classifier::prediction::Batch
111 {
112 public:
113  typedef classifier::prediction::Batch super;
114 
115  typedef algorithms::stump::classification::prediction::Input InputType;
116  typedef typename super::ParameterType ParameterType;
117  typedef typename super::ResultType ResultType;
118 
119  InputType input;
121  Batch(size_t nClasses = 2);
122 
129  Batch(const Batch<algorithmFPType, method> &other);
130 
131  virtual ~Batch()
132  {
133  delete _par;
134  }
135 
140  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
141 
146  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
147 
152  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
153 
158  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
159 
165  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
166  {
167  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
168  }
169 
170 protected:
171  using classifier::prediction::Batch::_result;
172 
173  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
174  {
175  return new Batch<algorithmFPType, method>(*this);
176  }
177 
178  services::Status allocateResult() DAAL_C11_OVERRIDE
179  {
180  services::Status s = _result->allocate<algorithmFPType>(&input, _par, (int)method);
181  _res = _result.get();
182  return s;
183  }
184 
185  void initialize()
186  {
187  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
188  _in = &input;
189  }
190 };
191 }
192 using interface1::BatchContainer;
193 using interface1::Batch;
194 
195 } // namespace daal::algorithms::stump::classification::prediction
197 }
198 }
199 }
200 } // namespace daal
201 #endif
daal::algorithms::stump::classification::prediction::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::batch
Definition: daal_defines.h:112
daal::algorithms::stump::classification::prediction::interface1::BatchContainer
Provides methods to run implementations of the decision stump prediction algorithm. It is associated with the daal::algorithms::stump::classification::prediction::interface1::Batch class and supports methods to run based on the decision stump model.
Definition: stump_classification_predict.h:73
daal::algorithms::stump::classification::prediction::interface1::Batch
Predicts results of the decision stump classification.
Definition: stump_classification_predict.h:110
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::stump::classification::prediction::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: stump_classification_predict.h:165
daal::algorithms::stump::classification::prediction::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::stump::classification::prediction::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::stump::classification::prediction::interface1::Batch::parameter
ParameterType & parameter()
Definition: stump_classification_predict.h:140
daal::algorithms::stump::classification::prediction::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: stump_classification_predict.h:158
daal::algorithms::stump::classification::prediction::Method
Method
Definition: stump_classification_predict.h:53
daal::algorithms::stump::classification::prediction::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: stump_classification_predict.h:146
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::stump::classification::prediction::defaultDense
Definition: stump_classification_predict.h:55
daal::algorithms::stump::classification::prediction::interface1::Batch::input
InputType input
Definition: stump_classification_predict.h:119
daal::algorithms::stump::classification::prediction::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: stump_classification_predict.h:152

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