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

multi_class_classifier_model_builder.h
1 /* file: multi_class_classifier_model_builder.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 #ifndef __MULTI_CLASS_CLASSIFIER_MODEL_BUILDER_H__
19 #define __MULTI_CLASS_CLASSIFIER_MODEL_BUILDER_H__
20 
21 #include "algorithms/multi_class_classifier/multi_class_classifier_model.h"
22 #include "algorithms/multi_class_classifier/multi_class_classifier_train_types.h"
23 namespace daal
24 {
25 namespace algorithms
26 {
36 namespace multi_class_classifier
37 {
38 
42 namespace interface1
43 {
55 template<training::Method method = training::oneAgainstOne>
56 class DAAL_EXPORT ModelBuilder
57 {
58 public:
64  ModelBuilder(size_t nFeatures, size_t nClasses): _nFeatures(nFeatures), _nClasses(nClasses)
65  {
66  _par = services::SharedPtr<ParameterBase>(new ParameterBase(_nClasses));
67  if(_par.get())
68  {
69  _modelPtr = Model::create(_nFeatures, _par.get(), &_s);
70  }
71  else
72  {
73  _s = services::Status(services::ErrorMemoryAllocationFailed);
74  }
75  }
76 
83  void setTwoClassClassifierModel(size_t negativeClassIdx, size_t positiveClassIdx, const classifier::ModelPtr& model)
84  {
85  if(negativeClassIdx >= positiveClassIdx)
86  {
87  _s |= services::Status(services::ErrorIncorrectParameter);
88  }
89 
90  if(!_s)
91  {
92  services::throwIfPossible(_s);
93  return;
94  }
95  size_t imodel = positiveClassIdx * (positiveClassIdx - 1)/2 + negativeClassIdx;
96 
97  _modelPtr->setTwoClassClassifierModel(imodel, model);
98  }
99 
104  ModelPtr getModel()
105  {
106  return _modelPtr;
107  }
108 
113  services::Status getStatus()
114  {
115  return _s;
116  }
117 
118 protected:
119  ModelPtr _modelPtr;
120  services::SharedPtr<ParameterBase> _par;
121  services::Status _s;
122  size_t _nFeatures;
123  size_t _nClasses;
124 };
125 
126 } // namespace interface1
127 
128 using interface1::ModelBuilder;
129 
130 } // namespace multi_class_classifier
132 } // namespace algorithms
133 } // namespace daal
134 #endif
daal::algorithms::multi_class_classifier::interface1::Model::create
static services::SharedPtr< Model > create(size_t nFeatures, const interface1::ParameterBase *par, services::Status *stat=NULL)
daal::algorithms::multi_class_classifier::interface1::ModelBuilder::getStatus
services::Status getStatus()
Definition: multi_class_classifier_model_builder.h:113
daal::algorithms::multi_class_classifier::interface1::ModelBuilder::getModel
ModelPtr getModel()
Definition: multi_class_classifier_model_builder.h:104
daal::algorithms::multi_class_classifier::interface1::ModelBuilder::setTwoClassClassifierModel
void setTwoClassClassifierModel(size_t negativeClassIdx, size_t positiveClassIdx, const classifier::ModelPtr &model)
Definition: multi_class_classifier_model_builder.h:83
daal::algorithms::elastic_net::training::model
Definition: elastic_net_training_types.h:109
daal::algorithms::multi_class_classifier::interface1::ModelBuilder
Builder for Model of the classifier trained by the multi_class_classifier::training::Batch algorithm...
Definition: multi_class_classifier_model_builder.h:56
daal::services::ErrorIncorrectParameter
Definition: error_indexes.h:99
daal::services::ErrorMemoryAllocationFailed
Definition: error_indexes.h:150
daal::algorithms::multi_class_classifier::interface1::ParameterBase
Parameters of the multi-class classifier algorithm.
Definition: multi_class_classifier_model.h:65
daal::algorithms::multi_class_classifier::interface1::ModelBuilder::ModelBuilder
ModelBuilder(size_t nFeatures, size_t nClasses)
Definition: multi_class_classifier_model_builder.h:64

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