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

stump_predict.h
1 /* file: stump_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_PREDICT_H__
25 #define __STUMP_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/weak_learner/weak_learner_predict.h"
29 #include "algorithms/stump/stump_predict_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace stump
36 {
45 namespace prediction
46 {
51 enum Method
52 {
53  defaultDense = 0
54 };
55 
59 namespace interface1
60 {
70 template<typename algorithmFPType, Method method, CpuType cpu>
71 class BatchContainer : public PredictionContainerIface
72 {
73 public:
78  BatchContainer(daal::services::Environment::env *daalEnv);
80  ~BatchContainer();
84  services::Status compute() DAAL_C11_OVERRIDE;
85 };
86 
107 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
108 class Batch : public weak_learner::prediction::Batch
109 {
110 public:
111  typedef weak_learner::prediction::Batch super;
112 
113  typedef algorithms::stump::prediction::Input InputType;
114  typedef typename super::ParameterType ParameterType;
115  typedef typename super::ResultType ResultType;
116 
117  InputType input;
119  Batch()
120  {
121  initialize();
122  }
123 
130  Batch(const Batch<algorithmFPType, method> &other) : weak_learner::prediction::Batch(other), input(other.input)
131  {
132  initialize();
133  }
134 
135  ~Batch() {}
136 
141  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
142 
147  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
148 
154  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
155  {
156  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
157  }
158 
159 protected:
160  using weak_learner::prediction::Batch::_result;
161 
162  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
163  {
164  return new Batch<algorithmFPType, method>(*this);
165  }
166 
167  services::Status allocateResult() DAAL_C11_OVERRIDE
168  {
169  services::Status s = _result->allocate<algorithmFPType>(&input, 0, 0);
170  _res = _result.get();
171  return s;
172  }
173 
174  void initialize()
175  {
176  _in = &input;
177  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
178  _par = NULL;
179  }
180 };
181 } // namespace interface1
182 using interface1::BatchContainer;
183 using interface1::Batch;
184 
185 } // namespace daal::algorithms::stump::prediction
187 }
188 }
189 } // namespace daal
190 #endif
daal::algorithms::stump::prediction::defaultDense
Definition: stump_predict.h:53
daal::batch
Definition: daal_defines.h:112
daal::algorithms::stump::prediction::interface1::Batch
Predicts results of the decision stump classification.
Definition: stump_predict.h:108
daal::algorithms::stump::prediction::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: stump_predict.h:141
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::stump::prediction::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: stump_predict.h:147
daal::algorithms::stump::prediction::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::stump::prediction::interface1::BatchContainer::~BatchContainer
~BatchContainer()
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::prediction::Method
Method
Definition: stump_predict.h:51
daal::algorithms::stump::prediction::interface1::Batch::input
InputType input
Definition: stump_predict.h:117
daal::algorithms::stump::prediction::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::stump::prediction::interface1::BatchContainer
Provides methods to run implementations of the decision stump prediction algorithm. It is associated with the daal::algorithms::stump::prediction::interface1::Batch class and supports methods to run based on the decision stump model.
Definition: stump_predict.h:71
daal::algorithms::stump::prediction::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: stump_predict.h:130
daal::algorithms::stump::prediction::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: stump_predict.h:154

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