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

brownboost_model.h
1 /* file: brownboost_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 Brown Boost model.
21 //--
22 */
23 
24 #ifndef __BROWN_BOOST_MODEL_H__
25 #define __BROWN_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 brownboost
42 {
43 
47 namespace interface1
48 {
59 /* [interface1::Parameter source code] */
60 struct DAAL_EXPORT Parameter : public boosting::Parameter
61 {
63  DAAL_DEPRECATED Parameter();
64 
75  DAAL_DEPRECATED Parameter(services::SharedPtr<weak_learner::training::Batch> wlTrainForParameter,
76  services::SharedPtr<weak_learner::prediction::Batch> wlPredictForParameter,
77  double acc = 0.3, size_t maxIter = 10, double nrAcc = 1.0e-3, size_t nrMaxIter = 100, double dcThreshold = 1.0e-2);
78 
79  double accuracyThreshold;
80  size_t maxIterations;
81  double newtonRaphsonAccuracyThreshold;
82  size_t newtonRaphsonMaxIterations;
83  double degenerateCasesThreshold;
85  DAAL_DEPRECATED services::Status check() const DAAL_C11_OVERRIDE;
86 };
87 /* [interface1::Parameter source code] */
88 
97 class DAAL_EXPORT Model : public boosting::Model
98 {
99 public:
100  DECLARE_MODEL(Model, classifier::Model)
101 
102 
109  template <typename modelFPType>
110  DAAL_EXPORT DAAL_DEPRECATED Model(size_t nFeatures, modelFPType dummy);
111 
116  DAAL_DEPRECATED Model() : boosting::Model(), _alpha() { }
117 
118 
125  template<typename modelFPType>
126  DAAL_EXPORT DAAL_DEPRECATED static services::SharedPtr<Model> create(size_t nFeatures, services::Status *stat = NULL);
127 
128  DAAL_DEPRECATED_VIRTUAL virtual ~Model() { }
129 
136  DAAL_DEPRECATED data_management::NumericTablePtr getAlpha();
137 
138 protected:
139  data_management::NumericTablePtr _alpha; /* Boosting coefficients table */
140 
141  template<typename Archive, bool onDeserialize>
142  services::Status serialImpl(Archive *arch)
143  {
144  services::Status st = boosting::Model::serialImpl<Archive, onDeserialize>(arch);
145  if (!st)
146  return st;
147  arch->setSharedPtrObj(_alpha);
148 
149  return st;
150  }
151 
152  template <typename modelFPType>
153  DAAL_EXPORT Model(size_t nFeatures, modelFPType dummy, services::Status &st);
154 
155 }; // class Model
156 typedef services::SharedPtr<Model> ModelPtr;
158 } // namespace interface1
159 
163 namespace interface2
164 {
175 /* [Parameter source code] */
176 struct DAAL_EXPORT Parameter : public classifier::Parameter
177 {
179  Parameter();
180 
191  Parameter(services::SharedPtr<classifier::training::Batch> wlTrainForParameter,
192  services::SharedPtr<classifier::prediction::Batch> wlPredictForParameter,
193  double acc = 0.3, size_t maxIter = 10, double nrAcc = 1.0e-3, size_t nrMaxIter = 100, double dcThreshold = 1.0e-2);
194 
195  services::SharedPtr<classifier::training::Batch> weakLearnerTraining;
196  services::SharedPtr<classifier::prediction::Batch> weakLearnerPrediction;
197  double accuracyThreshold;
198  size_t maxIterations;
199  double newtonRaphsonAccuracyThreshold;
200  size_t newtonRaphsonMaxIterations;
201  double degenerateCasesThreshold;
202  services::Status check() const DAAL_C11_OVERRIDE;
203 };
204 /* [Parameter source code] */
205 
214 class DAAL_EXPORT Model : public classifier::Model
215 {
216 public:
217  DECLARE_MODEL(Model, classifier::Model)
218 
219 
226  template <typename modelFPType>
227  DAAL_EXPORT Model(size_t nFeatures, modelFPType dummy);
228 
233  Model(size_t nFeatures = 0) : _models(new data_management::DataCollection()), _nFeatures(nFeatures), _alpha() { }
234 
235 
242  template<typename modelFPType>
243  DAAL_EXPORT static services::SharedPtr<Model> create(size_t nFeatures, services::Status *stat = NULL);
244 
245  virtual ~Model() { }
246 
251  size_t getNumberOfWeakLearners() const;
252 
258  classifier::ModelPtr getWeakLearnerModel(size_t idx) const;
259 
264  void addWeakLearnerModel(classifier::ModelPtr model);
265 
269  void clearWeakLearnerModels();
270 
275  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE { return _nFeatures; }
276 
283  data_management::NumericTablePtr getAlpha();
284 
285 protected:
286  size_t _nFeatures;
287  data_management::DataCollectionPtr _models;
288  data_management::NumericTablePtr _alpha; /* Boosting coefficients table */
289 
290  template<typename Archive, bool onDeserialize>
291  services::Status serialImpl(Archive *arch)
292  {
293  services::Status st;
294  DAAL_CHECK_STATUS(st, (classifier::Model::serialImpl<Archive, onDeserialize>(arch)));
295  arch->set(_nFeatures);
296  arch->setSharedPtrObj(_models);
297  arch->setSharedPtrObj(_alpha);
298 
299  return st;
300  }
301 
302  template <typename modelFPType>
303  DAAL_EXPORT Model(size_t nFeatures, modelFPType dummy, services::Status &st);
304 
305 }; // class Model
306 typedef services::SharedPtr<Model> ModelPtr;
308 } // namespace interface2
309 using interface2::Parameter;
310 using interface2::Model;
311 using interface2::ModelPtr;
312 
313 } // namespace daal::algorithms::brownboost
314 }
315 } // namespace daal
316 #endif
daal::algorithms::brownboost::interface1::Parameter::newtonRaphsonAccuracyThreshold
double newtonRaphsonAccuracyThreshold
Definition: brownboost_model.h:81
daal::algorithms::brownboost::interface2::Parameter::newtonRaphsonMaxIterations
size_t newtonRaphsonMaxIterations
Definition: brownboost_model.h:200
daal::algorithms::brownboost::interface1::Parameter
BrownBoost algorithm parameters.
Definition: brownboost_model.h:60
daal::algorithms::brownboost::interface2::Model::getNumberOfFeatures
size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE
Definition: brownboost_model.h:275
daal::algorithms::brownboost::interface1::Parameter::newtonRaphsonMaxIterations
size_t newtonRaphsonMaxIterations
Definition: brownboost_model.h:82
daal::algorithms::brownboost::interface1::Parameter::degenerateCasesThreshold
double degenerateCasesThreshold
Definition: brownboost_model.h:83
daal::algorithms::brownboost::interface1::Parameter::maxIterations
size_t maxIterations
Definition: brownboost_model.h:80
daal::algorithms::brownboost::interface2::Parameter::weakLearnerTraining
services::SharedPtr< classifier::training::Batch > weakLearnerTraining
Definition: brownboost_model.h:195
daal::algorithms::brownboost::interface2::Parameter::degenerateCasesThreshold
double degenerateCasesThreshold
Definition: brownboost_model.h:201
daal::algorithms::brownboost::interface2::Model::Model
Model(size_t nFeatures=0)
Definition: brownboost_model.h:233
daal::algorithms::elastic_net::training::model
Definition: elastic_net_training_types.h:109
daal::algorithms::brownboost::interface2::Parameter::weakLearnerPrediction
services::SharedPtr< classifier::prediction::Batch > weakLearnerPrediction
Definition: brownboost_model.h:196
daal::algorithms::brownboost::interface2::Parameter::accuracyThreshold
double accuracyThreshold
Definition: brownboost_model.h:197
daal::algorithms::brownboost::interface2::Parameter::maxIterations
size_t maxIterations
Definition: brownboost_model.h:198
daal::algorithms::brownboost::interface1::Model
Model of the classifier trained by the brownboost::training::Batch algorithm.
Definition: brownboost_model.h:97
daal::algorithms::brownboost::interface1::Parameter::accuracyThreshold
double accuracyThreshold
Definition: brownboost_model.h:79
daal::algorithms::brownboost::interface2::Parameter::newtonRaphsonAccuracyThreshold
double newtonRaphsonAccuracyThreshold
Definition: brownboost_model.h:199
daal::algorithms::brownboost::interface1::Model::Model
DAAL_DEPRECATED Model()
Definition: brownboost_model.h:116

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