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

stump_classification_training_batch.h
1 /* file: stump_classification_training_batch.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 training
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __STUMP_CLASSIFICATION_TRAINING_BATCH_H__
26 #define __STUMP_CLASSIFICATION_TRAINING_BATCH_H__
27 
28 #include "algorithms/classifier/classifier_training_batch.h"
29 #include "algorithms/stump/stump_classification_training_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace stump
36 {
37 namespace classification
38 {
39 namespace training
40 {
41 
42 namespace interface1
43 {
58 template<typename algorithmFPType, Method method, CpuType cpu>
59 class BatchContainer : public TrainingContainerIface<batch>
60 {
61 public:
67  BatchContainer(daal::services::Environment::env *daalEnv);
69  ~BatchContainer();
73  services::Status compute() DAAL_C11_OVERRIDE;
74 };
75 
93 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
94 class DAAL_EXPORT Batch : public classifier::training::Batch
95 {
96 public:
97  typedef classifier::training::Batch super;
98 
99  typedef typename super::InputType InputType;
100  typedef algorithms::stump::classification::Parameter ParameterType;
101  typedef algorithms::stump::classification::training::Result ResultType;
102 
103  InputType input;
105  Batch(size_t nClasses = 2);
106 
113  Batch(const Batch<algorithmFPType, method> &other);
114 
115  virtual ~Batch()
116  {
117  delete _par;
118  }
119 
124  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
125 
130  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
131 
136  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
137 
142  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
143 
148  training::ResultPtr getResult()
149  {
150  return ResultType::cast(_result);
151  }
152 
156  services::Status resetResult() DAAL_C11_OVERRIDE
157  {
158  _result.reset(new ResultType());
159  DAAL_CHECK(_result, services::ErrorNullResult)
160  _res = NULL;
161  return services::Status();
162  }
163 
169  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
170  {
171  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
172  }
173 
174 protected:
175  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
176  {
177  return new Batch<algorithmFPType, method>(*this);
178  }
179 
180  services::Status allocateResult() DAAL_C11_OVERRIDE
181  {
182  training::ResultPtr res = getResult();
183  DAAL_CHECK(res, services::ErrorNullResult);
184  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
185  _res = _result.get();
186  return s;
187  }
188 
189  void initialize()
190  {
191  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
192  _in = &input;
193  _result.reset(new ResultType());
194  }
195 };
197 }
198 using interface1::BatchContainer;
199 using interface1::Batch;
200 
201 } // namespace daal::algorithms::stump::classification::training
202 }
203 }
204 }
205 } // namespace daal
206 #endif // __stump__classification_TRAINING_BATCH_H__
daal::algorithms::stump::classification::training::interface1::BatchContainer
Provides methods to run implementations of the the decision stump training algorithm. It is associated with the daal::algorithms::stump::classification::training::Batch class and supports methods to train the decision stump model.
Definition: stump_classification_training_batch.h:59
daal::batch
Definition: daal_defines.h:112
daal::algorithms::stump::classification::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: stump_classification_training_batch.h:156
daal::algorithms::stump::classification::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: stump_classification_training_batch.h:136
daal::algorithms::stump::classification::training::interface1::Batch
Trains the decision stump model.
Definition: stump_classification_training_batch.h:94
daal::algorithms::stump::classification::training::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: stump_classification_training_batch.h:130
daal::algorithms::stump::classification::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: stump_classification_training_batch.h:142
daal::algorithms::stump::classification::training::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::stump::classification::training::interface1::Batch::parameter
ParameterType & parameter()
Definition: stump_classification_training_batch.h:124
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::stump::classification::training::interface1::Batch::getResult
training::ResultPtr getResult()
Definition: stump_classification_training_batch.h:148
daal::algorithms::stump::classification::training::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::stump::classification::training::interface1::Batch::input
InputType input
Definition: stump_classification_training_batch.h:103
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::stump::classification::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: stump_classification_training_batch.h:169
daal::algorithms::stump::classification::training::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE

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