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

stump_training_batch.h
1 /* file: stump_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_TRAINING_BATCH_H__
26 #define __STUMP_TRAINING_BATCH_H__
27 
28 #include "algorithms/weak_learner/weak_learner_training_batch.h"
29 #include "algorithms/stump/stump_training_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace stump
36 {
37 namespace training
38 {
39 
40 namespace interface1
41 {
56 template<typename algorithmFPType, Method method, CpuType cpu>
57 class BatchContainer : public TrainingContainerIface<batch>
58 {
59 public:
65  BatchContainer(daal::services::Environment::env *daalEnv);
67  ~BatchContainer();
71  services::Status compute() DAAL_C11_OVERRIDE;
72 };
73 
91 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
92 class DAAL_EXPORT Batch : public weak_learner::training::Batch
93 {
94 public:
95  typedef weak_learner::training::Batch super;
96 
97  typedef typename super::InputType InputType;
98  typedef typename super::ParameterType ParameterType;
99  typedef algorithms::stump::training::Result ResultType;
100 
101  ParameterType parameter;
102  InputType input;
104  Batch()
105  {
106  initialize();
107  }
108 
115  Batch(const Batch<algorithmFPType, method> &other) : weak_learner::training::Batch(other),
116  parameter(other.parameter), input(other.input)
117  {
118  initialize();
119  }
120 
121  virtual ~Batch() {}
122 
127  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
128 
133  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
134 
139  training::ResultPtr getResult()
140  {
141  return ResultType::cast(_result);
142  }
143 
147  services::Status resetResult() DAAL_C11_OVERRIDE
148  {
149  _result.reset(new ResultType());
150  DAAL_CHECK(_result, services::ErrorNullResult)
151  _res = NULL;
152  return services::Status();
153  }
154 
160  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
161  {
162  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
163  }
164 
165 protected:
166  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
167  {
168  return new Batch<algorithmFPType, method>(*this);
169  }
170 
171  services::Status allocateResult() DAAL_C11_OVERRIDE
172  {
173  training::ResultPtr res = getResult();
174  DAAL_CHECK(res, services::ErrorNullResult);
175  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
176  _res = _result.get();
177  return s;
178  }
179 
180  void initialize()
181  {
182  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
183  _in = &input;
184  _par = &parameter;
185  _result.reset(new ResultType());
186  }
187 };
189 } // namespace interface1
190 using interface1::BatchContainer;
191 using interface1::Batch;
192 
193 } // namespace daal::algorithms::stump::training
194 }
195 }
196 } // namespace daal
197 #endif // __STUMP_TRAINING_BATCH_H__
daal::algorithms::stump::training::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::stump::training::interface1::Batch::input
InputType input
Definition: stump_training_batch.h:102
daal::batch
Definition: daal_defines.h:112
daal::algorithms::stump::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:133
daal::algorithms::stump::training::interface1::Batch::getResult
training::ResultPtr getResult()
Definition: stump_training_batch.h:139
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::stump::training::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::stump::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: stump_training_batch.h:160
daal::algorithms::stump::training::interface1::BatchContainer
Provides methods to run implementations of the the decision stump training algorithm. It is associated with the daal::algorithms::stump::training::Batch class and supports methods to train the decision stump model.
Definition: stump_training_batch.h:57
daal::algorithms::stump::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:127
daal::algorithms::stump::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: stump_training_batch.h:115
daal::algorithms::stump::training::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::stump::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:147
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::training::interface1::Batch
Trains the decision stump model.
Definition: stump_training_batch.h:92
daal::algorithms::stump::training::interface1::Batch::parameter
ParameterType parameter
Definition: stump_training_batch.h:101

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