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

adaboost_model.h
1 /* file: adaboost_model.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 class defining Ada Boost model.
21 //--
22 */
23 
24 #ifndef __ADA_BOOST_MODEL_H__
25 #define __ADA_BOOST_MODEL_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "data_management/data/homogen_numeric_table.h"
29 #include "algorithms/boosting/boosting_model.h"
30 #include "algorithms/classifier/classifier_model.h"
31 #include "algorithms/classifier/classifier_training_batch.h"
32 #include "algorithms/classifier/classifier_predict.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
41 namespace adaboost
42 {
46 namespace interface1
47 {
58 /* [interface1::Parameter source code] */
59 struct DAAL_EXPORT Parameter : public boosting::Parameter
60 {
62  DAAL_DEPRECATED Parameter();
63 
71  DAAL_DEPRECATED Parameter(services::SharedPtr<weak_learner::training::Batch> wlTrainForParameter,
72  services::SharedPtr<weak_learner::prediction::Batch> wlPredictForParameter,
73  double acc = 0.0, size_t maxIter = 10);
74 
75  double accuracyThreshold;
76  size_t maxIterations;
78  DAAL_DEPRECATED services::Status check() const DAAL_C11_OVERRIDE;
79 };
80 /* [interface1::Parameter source code] */
81 
90 class DAAL_EXPORT Model : public boosting::Model
91 {
92 public:
93  DECLARE_MODEL(Model, classifier::Model)
94 
95 
102  template <typename modelFPType>
103  DAAL_EXPORT DAAL_DEPRECATED Model(size_t nFeatures, modelFPType dummy);
104 
109  DAAL_DEPRECATED Model() : boosting::Model(), _alpha() {}
110 
117  template<typename modelFPType>
118  DAAL_EXPORT DAAL_DEPRECATED static services::SharedPtr<Model> create(size_t nFeatures, services::Status *stat = NULL);
119 
120  virtual ~Model() { }
121 
128  DAAL_DEPRECATED data_management::NumericTablePtr getAlpha() const;
129 
130 protected:
131  data_management::NumericTablePtr _alpha; /* Boosting coefficients table */
132 
133  template<typename Archive, bool onDeserialize>
134  services::Status serialImpl(Archive *arch)
135  {
136  services::Status st = boosting::Model::serialImpl<Archive, onDeserialize>(arch);
137  if (!st)
138  return st;
139  arch->setSharedPtrObj(_alpha);
140 
141  return st;
142  }
143 
144  template <typename modelFPType>
145  DAAL_EXPORT Model(size_t nFeatures, modelFPType dummy, services::Status &st);
146 
147 }; // class Model
148 typedef services::SharedPtr<Model> ModelPtr;
150 } // namespace interface1
151 
156 enum ResultToComputeId
157 {
158  computeWeakLearnersErrors = 0x00000001ULL,
159 };
163 namespace interface2
164 {
175 /* [Parameter source code] */
176 struct DAAL_EXPORT Parameter : public classifier::Parameter
177 {
182  Parameter(size_t nClasses = 2);
183 
194  Parameter(services::SharedPtr<classifier::training::Batch> wlTrainForParameter,
195  services::SharedPtr<classifier::prediction::Batch> wlPredictForParameter,
196  double acc = 0.0, size_t maxIter = 10, double learnRate = 1.0, DAAL_UINT64 resToCompute = computeWeakLearnersErrors, size_t nCl = 2);
197 
198  services::SharedPtr<classifier::training::Batch> weakLearnerTraining;
199  services::SharedPtr<classifier::prediction::Batch> weakLearnerPrediction;
200  double accuracyThreshold;
201  size_t maxIterations;
202  double learningRate;
203  DAAL_UINT64 resultsToCompute;
204  services::Status check() const DAAL_C11_OVERRIDE;
205 };
206 /* [Parameter source code] */
207 
216 class DAAL_EXPORT Model : public classifier::Model
217 {
218 public:
219  DECLARE_MODEL(Model, classifier::Model)
220 
221 
228  template <typename modelFPType>
229  DAAL_EXPORT Model(size_t nFeatures, modelFPType dummy);
230 
235  Model(size_t nFeatures = 0) : _models(new data_management::DataCollection()), _nFeatures(nFeatures), _alpha() {}
236 
243  template<typename modelFPType>
244  DAAL_EXPORT static services::SharedPtr<Model> create(size_t nFeatures, services::Status *stat = NULL);
245 
246  virtual ~Model() { }
247 
252  size_t getNumberOfWeakLearners() const;
253 
259  classifier::ModelPtr getWeakLearnerModel(size_t idx) const;
260 
265  void addWeakLearnerModel(classifier::ModelPtr model);
266 
270  void clearWeakLearnerModels();
271 
276  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE { return _nFeatures; }
277 
284  data_management::NumericTablePtr getAlpha() const;
285 
286 protected:
287  size_t _nFeatures;
288  data_management::DataCollectionPtr _models;
289  data_management::NumericTablePtr _alpha; /* Boosting coefficients table */
290 
291  template<typename Archive, bool onDeserialize>
292  services::Status serialImpl(Archive *arch)
293  {
294  services::Status st;
295  DAAL_CHECK_STATUS(st, (classifier::Model::serialImpl<Archive, onDeserialize>(arch)));
296  arch->set(_nFeatures);
297  arch->setSharedPtrObj(_models);
298  arch->setSharedPtrObj(_alpha);
299 
300  return st;
301  }
302 
303  template <typename modelFPType>
304  DAAL_EXPORT Model(size_t nFeatures, modelFPType dummy, services::Status &st);
305 
306 }; // class Model
307 typedef services::SharedPtr<Model> ModelPtr;
309 } // namespace interface2
310 using interface2::Parameter;
311 using interface2::Model;
312 using interface2::ModelPtr;
313 
314 } // namespace adaboost
315 } // namespace algorithms
316 } // namespace daal
317 #endif
daal::algorithms::adaboost::interface2::Parameter::weakLearnerTraining
services::SharedPtr< classifier::training::Batch > weakLearnerTraining
Definition: adaboost_model.h:198
daal::algorithms::adaboost::interface2::Model::getNumberOfFeatures
size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE
Definition: adaboost_model.h:276
daal::algorithms::adaboost::interface1::Model::Model
DAAL_DEPRECATED Model()
Definition: adaboost_model.h:109
daal::algorithms::adaboost::interface2::Parameter::accuracyThreshold
double accuracyThreshold
Definition: adaboost_model.h:200
daal::algorithms::adaboost::interface2::Parameter::maxIterations
size_t maxIterations
Definition: adaboost_model.h:201
daal::algorithms::adaboost::interface2::Parameter::weakLearnerPrediction
services::SharedPtr< classifier::prediction::Batch > weakLearnerPrediction
Definition: adaboost_model.h:199
daal::algorithms::adaboost::interface1::Parameter::accuracyThreshold
double accuracyThreshold
Definition: adaboost_model.h:75
daal::algorithms::adaboost::interface2::Parameter::resultsToCompute
DAAL_UINT64 resultsToCompute
Definition: adaboost_model.h:203
daal::algorithms::elastic_net::training::model
Definition: elastic_net_training_types.h:109
daal::algorithms::adaboost::interface1::Parameter
AdaBoost algorithm parameters.
Definition: adaboost_model.h:59
daal::algorithms::adaboost::interface1::Model
Model of the classifier trained by the adaboost::training::Batch algorithm.
Definition: adaboost_model.h:90
daal::algorithms::adaboost::ResultToComputeId
ResultToComputeId
Definition: adaboost_model.h:156
daal::algorithms::adaboost::interface2::Model::Model
Model(size_t nFeatures=0)
Definition: adaboost_model.h:235
daal::algorithms::adaboost::interface2::Parameter::learningRate
double learningRate
Definition: adaboost_model.h:202
daal::algorithms::adaboost::interface1::Parameter::maxIterations
size_t maxIterations
Definition: adaboost_model.h:76

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