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

stump_training_batch.h
1 /* file: stump_training_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the interface for decision stump model-based training
45 // in the batch processing mode
46 //--
47 */
48 
49 #ifndef __STUMP_TRAINING_BATCH_H__
50 #define __STUMP_TRAINING_BATCH_H__
51 
52 #include "algorithms/weak_learner/weak_learner_training_batch.h"
53 #include "algorithms/stump/stump_training_types.h"
54 
55 namespace daal
56 {
57 namespace algorithms
58 {
59 namespace stump
60 {
61 namespace training
62 {
63 
64 namespace interface1
65 {
80 template<typename algorithmFPType, Method method, CpuType cpu>
81 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
82 {
83 public:
89  BatchContainer(daal::services::Environment::env *daalEnv);
91  ~BatchContainer();
95  services::Status compute() DAAL_C11_OVERRIDE;
96 };
97 
115 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
116 class DAAL_EXPORT Batch : public weak_learner::training::Batch
117 {
118 public:
119  classifier::Parameter parameter;
120  classifier::training::Input input;
122  Batch()
123  {
124  initialize();
125  }
126 
133  Batch(const Batch<algorithmFPType, method> &other) : weak_learner::training::Batch(other),
134  parameter(other.parameter), input(other.input)
135  {
136  initialize();
137  }
138 
139  virtual ~Batch() {}
140 
145  classifier::training::Input * getInput() DAAL_C11_OVERRIDE { return &input; }
146 
151  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
152 
157  training::ResultPtr getResult()
158  {
159  return Result::cast(_result);
160  }
161 
165  services::Status resetResult() DAAL_C11_OVERRIDE
166  {
167  _result.reset(new Result());
168  DAAL_CHECK(_result, services::ErrorNullResult)
169  _res = NULL;
170  return services::Status();
171  }
172 
178  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
179  {
180  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
181  }
182 
183 protected:
184  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
185  {
186  return new Batch<algorithmFPType, method>(*this);
187  }
188 
189  services::Status allocateResult() DAAL_C11_OVERRIDE
190  {
191  training::ResultPtr res = getResult();
192  DAAL_CHECK(res, services::ErrorNullResult);
193  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
194  _res = _result.get();
195  return s;
196  }
197 
198  void initialize()
199  {
200  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
201  _in = &input;
202  _par = &parameter;
203  _result.reset(new stump::training::Result());
204  }
205 };
207 } // namespace interface1
208 using interface1::BatchContainer;
209 using interface1::Batch;
210 
211 } // namespace daal::algorithms::stump::training
212 }
213 }
214 } // namespace daal
215 #endif // __STUMP_TRAINING_BATCH_H__
daal::algorithms::stump::training::interface1::Batch::input
classifier::training::Input input
Definition: stump_training_batch.h:120
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:81
daal
Definition: algorithm_base_common.h:57
daal::algorithms::stump::training::interface1::Batch::getInput
classifier::training::Input * getInput() DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:145
daal::algorithms::stump::training::interface1::Batch::parameter
classifier::Parameter parameter
Definition: stump_training_batch.h:119
daal::algorithms::stump::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: stump_training_batch.h:178
daal::batch
Definition: daal_defines.h:131
daal::algorithms::stump::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: stump_training_batch.h:133
daal::algorithms::stump::training::interface1::Batch::getResult
training::ResultPtr getResult()
Definition: stump_training_batch.h:157
daal::algorithms::stump::training::interface1::Batch
Trains the decision stump model.
Definition: stump_training_batch.h:116
daal::algorithms::stump::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:151
daal::algorithms::stump::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: stump_training_batch.h:165
daal::algorithms::stump::training::interface1::Result
Provides methods to access final results obtained with the compute() method of the decision stump tra...
Definition: stump_training_types.h:95
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:76

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