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

multi_class_classifier_train.h
1 /* file: multi_class_classifier_train.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 the interface for multi-class classifier model-based training
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __MULTI_CLASS_CLASSIFIER_TRAIN_H__
26 #define __MULTI_CLASS_CLASSIFIER_TRAIN_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "algorithms/classifier/classifier_training_batch.h"
32 #include "algorithms/multi_class_classifier/multi_class_classifier_train_types.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace multi_class_classifier
39 {
43 namespace training
44 {
45 
49 namespace interface1
50 {
63 template<typename algorithmFPType, Method method, CpuType cpu>
64 class BatchContainer : public TrainingContainerIface<batch>
65 {
66 public:
72  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
74  DAAL_DEPRECATED ~BatchContainer();
80  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
81 };
82 
100 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = oneAgainstOne>
101 class DAAL_EXPORT Batch : public classifier::training::interface1::Batch
102 {
103 public:
104  typedef classifier::training::interface1::Batch super;
105 
106  typedef typename super::InputType InputType;
107  typedef algorithms::multi_class_classifier::interface1::Parameter ParameterType;
108  typedef algorithms::multi_class_classifier::training::Result ResultType;
109 
110  ParameterType parameter;
111  InputType input;
117  DAAL_DEPRECATED Batch() : parameter(0)
118  {
119  initialize();
120  }
121 
126  DAAL_DEPRECATED Batch(size_t nClasses) : parameter(nClasses)
127  {
128  initialize();
129  }
130 
137  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) : classifier::training::interface1::Batch(other),
138  parameter(other.parameter), input(other.input)
139  {
140  initialize();
141  }
142 
143  DAAL_DEPRECATED ~Batch() {}
144 
149  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
150 
155  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
156 
161  DAAL_DEPRECATED ResultPtr getResult()
162  {
163  return ResultType::cast(_result);
164  }
165 
169  DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
170  {
171  _result.reset(new ResultType());
172  DAAL_CHECK(_result, services::ErrorNullResult);
173  _res = NULL;
174  return services::Status();
175  }
176 
182  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
183  {
184  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
185  }
186 
187 protected:
188  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
189  {
190  return new Batch<algorithmFPType, method>(*this);
191  }
192 
193  services::Status allocateResult() DAAL_C11_OVERRIDE
194  {
195  ResultPtr res = getResult();
196  DAAL_CHECK(_result, services::ErrorNullResult);
197  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
198  _res = _result.get();
199  return s;
200  }
201 
202  void initialize()
203  {
204  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
205  _in = &input;
206  _par = &parameter;
207  _result.reset(new ResultType());
208  }
209 };
211 } // namespace interface1
212 
216 namespace interface2
217 {
230 template<typename algorithmFPType, Method method, CpuType cpu>
231 class BatchContainer : public TrainingContainerIface<batch>
232 {
233 public:
239  BatchContainer(daal::services::Environment::env *daalEnv);
241  ~BatchContainer();
247  services::Status compute() DAAL_C11_OVERRIDE;
248 };
249 
267 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = oneAgainstOne>
268 class DAAL_EXPORT Batch : public classifier::training::Batch
269 {
270 public:
271  typedef classifier::training::Batch super;
272 
273  typedef typename super::InputType InputType;
274  typedef algorithms::multi_class_classifier::Parameter ParameterType;
275  typedef algorithms::multi_class_classifier::training::Result ResultType;
276 
277  ParameterType parameter;
278  InputType input;
284  DAAL_DEPRECATED Batch() : parameter(0)
285  {
286  initialize();
287  }
288 
293  Batch(size_t nClasses) : parameter(nClasses)
294  {
295  initialize();
296  }
297 
304  Batch(const Batch<algorithmFPType, method> &other) : classifier::training::Batch(other),
305  parameter(other.parameter), input(other.input)
306  {
307  initialize();
308  }
309 
310  ~Batch() {}
311 
316  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
317 
322  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
323 
328  ResultPtr getResult()
329  {
330  return ResultType::cast(_result);
331  }
332 
336  services::Status resetResult() DAAL_C11_OVERRIDE
337  {
338  _result.reset(new ResultType());
339  DAAL_CHECK(_result, services::ErrorNullResult);
340  _res = NULL;
341  return services::Status();
342  }
343 
349  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
350  {
351  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
352  }
353 
354 protected:
355  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
356  {
357  return new Batch<algorithmFPType, method>(*this);
358  }
359 
360  services::Status allocateResult() DAAL_C11_OVERRIDE
361  {
362  ResultPtr res = getResult();
363  DAAL_CHECK(_result, services::ErrorNullResult);
364  services::Status s = res->template allocate<algorithmFPType>(&input, _par, method);
365  _res = _result.get();
366  return s;
367  }
368 
369  void initialize()
370  {
371  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
372  _in = &input;
373  _par = &parameter;
374  _result.reset(new ResultType());
375  }
376 };
378 } // namespace interface2
379 using interface2::BatchContainer;
380 using interface2::Batch;
381 
382 } // namespace training
383 } // namespace multi_class_classifier
384 } // namespace algorithms
385 } //namespace daal
386 #endif
daal::algorithms::multi_class_classifier::training::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::multi_class_classifier::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: multi_class_classifier_train.h:117
daal::algorithms::classifier::training::interface1::Result
Provides methods to access final results obtained with the compute() method in the batch processing m...
Definition: classifier_training_types.h:198
daal::algorithms::multi_class_classifier::training::interface2::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:336
daal::algorithms::multi_class_classifier::training::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: multi_class_classifier_train.h:304
daal::algorithms::multi_class_classifier::training::interface2::Batch::parameter
ParameterType parameter
Definition: multi_class_classifier_train.h:277
daal::batch
Definition: daal_defines.h:112
daal::algorithms::multi_class_classifier::training::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: multi_class_classifier_train.h:182
daal::algorithms::multi_class_classifier::training::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:322
daal::algorithms::multi_class_classifier::training::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::multi_class_classifier::training::interface1::Batch::input
InputType input
Definition: multi_class_classifier_train.h:111
daal::algorithms::multi_class_classifier::training::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:316
daal::algorithms::multi_class_classifier::training::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:149
daal::algorithms::multi_class_classifier::training::interface2::BatchContainer
Class containing methods to compute the results of multi-class classifier model-based training...
Definition: multi_class_classifier_train.h:231
daal::algorithms::classifier::training::interface1::Batch
Algorithm class for training the classifier model.
Definition: classifier_training_batch.h:58
daal::algorithms::multi_class_classifier::training::interface1::Batch::resetResult
DAAL_DEPRECATED services::Status resetResult() DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:169
daal::algorithms::multi_class_classifier::training::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: multi_class_classifier_train.h:349
daal::algorithms::multi_class_classifier::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nClasses)
Definition: multi_class_classifier_train.h:126
daal::algorithms::multi_class_classifier::training::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::multi_class_classifier::training::interface2::Batch::getResult
ResultPtr getResult()
Definition: multi_class_classifier_train.h:328
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::multi_class_classifier::training::interface1::Batch::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: multi_class_classifier_train.h:161
daal_defines.h
daal::algorithms::multi_class_classifier::training::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::multi_class_classifier::interface1::Parameter
Optional multi-class classifier algorithm parameters that are used with the MultiClassClassifierWu pr...
Definition: multi_class_classifier_model.h:80
daal::algorithms::classifier::training::interface1::Input
Base class for the input objects in the training stage of the classification algorithms.
Definition: classifier_training_types.h:110
daal::algorithms::multi_class_classifier::training::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::multi_class_classifier::training::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::multi_class_classifier::training::interface1::Batch
Algorithm for the multi-class classifier model training.
Definition: multi_class_classifier_train.h:101
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:64
daal::algorithms::multi_class_classifier::training::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: multi_class_classifier_train.h:155
daal::algorithms::multi_class_classifier::training::interface2::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: multi_class_classifier_train.h:284
daal::algorithms::multi_class_classifier::training::interface2::Batch
Algorithm for the multi-class classifier model training.
Definition: multi_class_classifier_train.h:268
daal::algorithms::multi_class_classifier::training::interface1::Batch::parameter
ParameterType parameter
Definition: multi_class_classifier_train.h:110
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::multi_class_classifier::training::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: multi_class_classifier_train.h:137
daal::algorithms::multi_class_classifier::training::interface2::Batch::Batch
Batch(size_t nClasses)
Definition: multi_class_classifier_train.h:293
daal::algorithms::multi_class_classifier::training::interface2::Batch::input
InputType input
Definition: multi_class_classifier_train.h:278

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