C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 4

stump_training_batch.h
1 /* file: stump_training_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for decision stump model-based training
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __STUMP_TRAINING_BATCH_H__
24 #define __STUMP_TRAINING_BATCH_H__
25 
26 #include "algorithms/weak_learner/weak_learner_training_batch.h"
27 #include "algorithms/stump/stump_training_types.h"
28 
29 namespace daal
30 {
31 namespace algorithms
32 {
33 namespace stump
34 {
35 namespace training
36 {
37 
38 namespace interface1
39 {
54 template<typename algorithmFPType, Method method, CpuType cpu>
55 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
56 {
57 public:
63  BatchContainer(daal::services::Environment::env *daalEnv);
65  ~BatchContainer();
69  services::Status compute() DAAL_C11_OVERRIDE;
70 };
71 
89 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
90 class DAAL_EXPORT Batch : public weak_learner::training::Batch
91 {
92 public:
93  typedef weak_learner::training::Batch super;
94 
95  typedef typename super::InputType InputType;
96  typedef typename super::ParameterType ParameterType;
97  typedef algorithms::stump::training::Result ResultType;
98 
99  ParameterType parameter;
100  InputType input;
102  Batch()
103  {
104  initialize();
105  }
106 
113  Batch(const Batch<algorithmFPType, method> &other) : weak_learner::training::Batch(other),
114  parameter(other.parameter), input(other.input)
115  {
116  initialize();
117  }
118 
119  virtual ~Batch() {}
120 
125  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
126 
131  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
132 
137  training::ResultPtr getResult()
138  {
139  return ResultType::cast(_result);
140  }
141 
145  services::Status resetResult() DAAL_C11_OVERRIDE
146  {
147  _result.reset(new ResultType());
148  DAAL_CHECK(_result, services::ErrorNullResult)
149  _res = NULL;
150  return services::Status();
151  }
152 
158  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
159  {
160  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
161  }
162 
163 protected:
164  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
165  {
166  return new Batch<algorithmFPType, method>(*this);
167  }
168 
169  services::Status allocateResult() DAAL_C11_OVERRIDE
170  {
171  training::ResultPtr res = getResult();
172  DAAL_CHECK(res, services::ErrorNullResult);
173  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
174  _res = _result.get();
175  return s;
176  }
177 
178  void initialize()
179  {
180  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
181  _in = &input;
182  _par = &parameter;
183  _result.reset(new ResultType());
184  }
185 };
187 } // namespace interface1
188 using interface1::BatchContainer;
189 using interface1::Batch;
190 
191 } // namespace daal::algorithms::stump::training
192 }
193 }
194 } // namespace daal
195 #endif // __STUMP_TRAINING_BATCH_H__
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:55
daal
Definition: algorithm_base_common.h:31
daal::algorithms::stump::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:125
daal::algorithms::stump::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: stump_training_batch.h:158
daal::batch
Definition: daal_defines.h:110
daal::algorithms::stump::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: stump_training_batch.h:113
daal::algorithms::stump::training::interface1::Batch::getResult
training::ResultPtr getResult()
Definition: stump_training_batch.h:137
daal::algorithms::stump::training::interface1::Batch
Trains the decision stump model.
Definition: stump_training_batch.h:90
daal::algorithms::stump::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:131
daal::algorithms::stump::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:145
daal::algorithms::stump::training::interface1::Batch::input
InputType input
Definition: stump_training_batch.h:100
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50
daal::algorithms::stump::training::interface1::Batch::parameter
ParameterType parameter
Definition: stump_training_batch.h:99

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