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

stump_regression_training_batch.h
1 /* file: stump_regression_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_REGRESSION_TRAINING_BATCH_H__
26 #define __STUMP_REGRESSION_TRAINING_BATCH_H__
27 
28 #include "algorithms/regression/regression_training_batch.h"
29 #include "algorithms/stump/stump_regression_training_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace stump
36 {
37 namespace regression
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 daal::algorithms::regression::training::Batch
95 {
96 public:
97  typedef daal::algorithms::regression::training::Batch super;
98 
99  typedef typename super::InputType InputType;
100  typedef algorithms::stump::regression::Parameter ParameterType;
101  typedef algorithms::stump::regression::training::Result ResultType;
102 
103  InputType input;
106  Batch();
107 
114  Batch(const Batch<algorithmFPType, method> & other);
115 
116  virtual ~Batch()
117  {
118  delete _par;
119  }
120 
125  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
126 
131  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
132 
137  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
138 
143  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
144 
149  ResultPtr getResult() { return ResultType::cast(_result); }
150 
154  services::Status resetResult() DAAL_C11_OVERRIDE
155  {
156  _result.reset(new ResultType());
157  DAAL_CHECK(_result, services::ErrorNullResult)
158  _res = NULL;
159  return services::Status();
160  }
161 
167  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
168  {
169  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
170  }
171 
172 protected:
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 = getResult()->template allocate<algorithmFPType>(&input, _par, 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  _result.reset(new ResultType());
190  }
191 };
193 }
194 using interface1::BatchContainer;
195 using interface1::Batch;
196 
197 } // namespace daal::algorithms::stump::regression::training
198 }
199 }
200 }
201 } // namespace daal
202 #endif // __stump__regression_TRAINING_BATCH_H__
daal::algorithms::stump::regression::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: stump_regression_training_batch.h:167
daal::batch
Definition: daal_defines.h:112
daal::algorithms::stump::regression::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: stump_regression_training_batch.h:154
daal::algorithms::stump::regression::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: stump_regression_training_batch.h:137
daal::algorithms::stump::regression::training::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::stump::regression::training::interface1::Batch::parameter
ParameterType & parameter()
Definition: stump_regression_training_batch.h:125
daal::algorithms::stump::regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: stump_regression_training_batch.h:143
daal::algorithms::stump::regression::training::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::stump::regression::training::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: stump_regression_training_batch.h:131
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::stump::regression::training::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::stump::regression::training::interface1::Batch
Trains the decision stump model.
Definition: stump_regression_training_batch.h:94
daal::algorithms::stump::regression::training::interface1::Batch::input
InputType input
Definition: stump_regression_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::regression::training::interface1::BatchContainer
Provides methods to run implementations of the the decision stump training algorithm. It is associated with the daal::algorithms::stump::regression::training::Batch class and supports methods to train the decision stump model.
Definition: stump_regression_training_batch.h:59
daal::algorithms::stump::regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: stump_regression_training_batch.h:149

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