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

multi_class_classifier_train.h
1 /* file: multi_class_classifier_train.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for multi-class classifier model-based training
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __MULTI_CLASS_CLASSIFIER_TRAIN_H__
24 #define __MULTI_CLASS_CLASSIFIER_TRAIN_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "algorithms/classifier/classifier_training_batch.h"
30 #include "algorithms/multi_class_classifier/multi_class_classifier_train_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace multi_class_classifier
37 {
41 namespace training
42 {
43 
47 namespace interface1
48 {
61 template<typename algorithmFPType, Method method, CpuType cpu>
62 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
63 {
64 public:
70  BatchContainer(daal::services::Environment::env *daalEnv);
72  ~BatchContainer();
78  services::Status compute() DAAL_C11_OVERRIDE;
79 };
80 
98 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = oneAgainstOne>
99 class DAAL_EXPORT Batch : public classifier::training::Batch
100 {
101 public:
102  typedef classifier::training::Batch super;
103 
104  typedef typename super::InputType InputType;
105  typedef algorithms::multi_class_classifier::Parameter ParameterType;
106  typedef algorithms::multi_class_classifier::training::Result ResultType;
107 
108  ParameterType parameter;
109  InputType input;
115  DAAL_DEPRECATED Batch() : parameter(0)
116  {
117  initialize();
118  }
119 
124  Batch(size_t nClasses) : parameter(nClasses)
125  {
126  initialize();
127  }
128 
135  Batch(const Batch<algorithmFPType, method> &other) : classifier::training::Batch(other),
136  parameter(other.parameter), input(other.input)
137  {
138  initialize();
139  }
140 
141  ~Batch() {}
142 
147  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
148 
153  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
154 
159  ResultPtr getResult()
160  {
161  return ResultType::cast(_result);
162  }
163 
167  services::Status resetResult() DAAL_C11_OVERRIDE
168  {
169  _result.reset(new ResultType());
170  DAAL_CHECK(_result, services::ErrorNullResult);
171  _res = NULL;
172  return services::Status();
173  }
174 
180  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
181  {
182  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
183  }
184 
185 protected:
186  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
187  {
188  return new Batch<algorithmFPType, method>(*this);
189  }
190 
191  services::Status allocateResult() DAAL_C11_OVERRIDE
192  {
193  ResultPtr res = getResult();
194  DAAL_CHECK(_result, services::ErrorNullResult);
195  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
196  _res = _result.get();
197  return s;
198  }
199 
200  void initialize()
201  {
202  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
203  _in = &input;
204  _par = &parameter;
205  _result.reset(new ResultType());
206  }
207 };
209 } // namespace interface1
210 using interface1::BatchContainer;
211 using interface1::Batch;
212 
213 } // namespace training
214 } // namespace multi_class_classifier
215 } // namespace algorithms
216 } //namespace daal
217 #endif
daal::algorithms::multi_class_classifier::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: multi_class_classifier_train.h:115
daal
Definition: algorithm_base_common.h:31
daal::algorithms::multi_class_classifier::training::interface1::Batch::input
InputType input
Definition: multi_class_classifier_train.h:109
daal::algorithms::multi_class_classifier::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:153
daal::algorithms::multi_class_classifier::training::interface1::Batch::Batch
Batch(size_t nClasses)
Definition: multi_class_classifier_train.h:124
daal::algorithms::multi_class_classifier::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: multi_class_classifier_train.h:159
daal::algorithms::multi_class_classifier::training::interface1::Batch::parameter
ParameterType parameter
Definition: multi_class_classifier_train.h:108
daal_defines.h
daal::algorithms::multi_class_classifier::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:167
daal::batch
Definition: daal_defines.h:106
daal::algorithms::multi_class_classifier::training::interface1::BatchContainer
Class containing methods to compute the results of multi-class classifier model-based training...
Definition: multi_class_classifier_train.h:62
daal::algorithms::multi_class_classifier::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: multi_class_classifier_train.h:135
daal::algorithms::multi_class_classifier::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: multi_class_classifier_train.h:180
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50
daal::algorithms::multi_class_classifier::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:147
daal::algorithms::multi_class_classifier::training::interface1::Batch
Algorithm for the multi-class classifier model training.
Definition: multi_class_classifier_train.h:99

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