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

multi_class_classifier_predict.h
1 /* file: multi_class_classifier_predict.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 prediction
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __MULTI_CLASS_CLASSIFIER_PREDICT_H__
26 #define __MULTI_CLASS_CLASSIFIER_PREDICT_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_predict.h"
32 #include "algorithms/multi_class_classifier/multi_class_classifier_predict_types.h"
33 #include "algorithms/multi_class_classifier/multi_class_classifier_train_types.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 namespace multi_class_classifier
40 {
44 namespace prediction
45 {
46 
50 namespace interface1
51 {
65 template<typename algorithmFPType, prediction::Method pmethod, training::Method tmethod, CpuType cpu>
66 class BatchContainer : public PredictionContainerIface
67 {
68 public:
74  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
76  DAAL_DEPRECATED ~BatchContainer();
82  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
83 };
84 
106 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, prediction::Method pmethod = defaultDense, training::Method tmethod = training::oneAgainstOne>
107 class Batch : public classifier::prediction::interface1::Batch
108 {
109 public:
110  typedef classifier::prediction::interface1::Batch super;
111 
112  typedef algorithms::multi_class_classifier::prediction::Input InputType;
113  typedef algorithms::multi_class_classifier::interface1::Parameter ParameterType;
114  typedef typename super::ResultType ResultType;
115 
116  InputType input;
117  ParameterType parameter;
123  DAAL_DEPRECATED Batch() : parameter(0)
124  {
125  initialize();
126  }
127 
132  DAAL_DEPRECATED Batch(size_t nClasses) : parameter(nClasses)
133  {
134  initialize();
135  }
136 
143  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, pmethod, tmethod> &other) : classifier::prediction::interface1::Batch(other),
144  parameter(other.parameter), input(other.input)
145  {
146  initialize();
147  }
148 
149  DAAL_DEPRECATED_VIRTUAL virtual ~Batch() {}
150 
155  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
156 
161  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)pmethod; }
162 
168  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, pmethod, tmethod> > clone() const
169  {
170  return services::SharedPtr<Batch<algorithmFPType, pmethod, tmethod> >(cloneImpl());
171  }
172 
173 protected:
174  virtual Batch<algorithmFPType, pmethod, tmethod> * cloneImpl() const DAAL_C11_OVERRIDE
175  {
176  return new Batch<algorithmFPType, pmethod, tmethod>(*this);
177  }
178 
179  services::Status allocateResult() DAAL_C11_OVERRIDE
180  {
181  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) pmethod);
182  _res = _result.get();
183  return s;
184  }
185 
186  void initialize()
187  {
188  _in = &input;
189  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, pmethod, tmethod)(&_env);
190  _par = &parameter;
191  }
192 };
194 } // namespace interface1
195 
199 namespace interface2
200 {
214 template<typename algorithmFPType, prediction::Method pmethod, training::Method tmethod, CpuType cpu>
215 class BatchContainer : public PredictionContainerIface
216 {
217 public:
223  BatchContainer(daal::services::Environment::env *daalEnv);
225  ~BatchContainer();
231  services::Status compute() DAAL_C11_OVERRIDE;
232 };
233 
255 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, prediction::Method pmethod = defaultDense, training::Method tmethod = training::oneAgainstOne>
256 class Batch : public classifier::prediction::Batch
257 {
258 public:
259  typedef classifier::prediction::Batch super;
260 
261  typedef algorithms::multi_class_classifier::prediction::Input InputType;
262  typedef algorithms::multi_class_classifier::Parameter ParameterType;
263  typedef typename super::ResultType ResultType;
264 
265  InputType input;
266  ParameterType parameter;
272  DAAL_DEPRECATED Batch() : parameter(0)
273  {
274  initialize();
275  }
276 
281  Batch(size_t nClasses) : parameter(nClasses)
282  {
283  initialize();
284  }
285 
292  Batch(const Batch<algorithmFPType, pmethod, tmethod> &other) : classifier::prediction::Batch(other),
293  parameter(other.parameter), input(other.input)
294  {
295  initialize();
296  }
297 
298  virtual ~Batch() {}
299 
304  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
305 
310  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)pmethod; }
311 
317  services::SharedPtr<Batch<algorithmFPType, pmethod, tmethod> > clone() const
318  {
319  return services::SharedPtr<Batch<algorithmFPType, pmethod, tmethod> >(cloneImpl());
320  }
321 
322 protected:
323 
324  virtual Batch<algorithmFPType, pmethod, tmethod> * cloneImpl() const DAAL_C11_OVERRIDE
325  {
326  return new Batch<algorithmFPType, pmethod, tmethod>(*this);
327  }
328 
329  services::Status allocateResult() DAAL_C11_OVERRIDE
330  {
331  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) pmethod);
332  _res = _result.get();
333  return s;
334  }
335 
336  void initialize()
337  {
338  _in = &input;
339  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, pmethod, tmethod)(&_env);
340  _par = &parameter;
341  }
342 };
344 } // namespace interface2
345 using interface2::BatchContainer;
346 using interface2::Batch;
347 
348 } // namespace prediction
349 } // namespace multi_class_classifier
350 } // namespace algorithms
351 } // namespace daal
352 #endif
daal::algorithms::multi_class_classifier::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: multi_class_classifier_predict.h:117
daal::algorithms::multi_class_classifier::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: multi_class_classifier_predict.h:155
daal::algorithms::multi_class_classifier::prediction::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::batch
Definition: daal_defines.h:112
daal::algorithms::multi_class_classifier::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: multi_class_classifier_predict.h:123
daal::algorithms::multi_class_classifier::prediction::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, pmethod, tmethod > &other)
Definition: multi_class_classifier_predict.h:292
daal::algorithms::multi_class_classifier::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, pmethod, tmethod > &other)
Definition: multi_class_classifier_predict.h:143
daal::algorithms::multi_class_classifier::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nClasses)
Definition: multi_class_classifier_predict.h:132
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::multi_class_classifier::prediction::interface1::Batch::input
InputType input
Definition: multi_class_classifier_predict.h:116
daal::algorithms::multi_class_classifier::prediction::interface2::Batch::Batch
Batch(size_t nClasses)
Definition: multi_class_classifier_predict.h:281
daal::algorithms::multi_class_classifier::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: multi_class_classifier_predict.h:310
daal::algorithms::classifier::prediction::interface1::Input
Input objects in the prediction stage of the classification algorithm.
Definition: classifier_predict_types.h:111
daal::algorithms::multi_class_classifier::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, pmethod, tmethod > > clone() const
Definition: multi_class_classifier_predict.h:317
daal_defines.h
daal::algorithms::multi_class_classifier::prediction::interface2::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: multi_class_classifier_predict.h:272
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::multi_class_classifier::prediction::interface2::Batch
Provides methods to run implementations of the multi-class classifier prediction algorithm.
Definition: multi_class_classifier_predict.h:256
daal::algorithms::classifier::prediction::interface1::Result
Provides methods to access prediction results obtained with the compute() method of the classifier pr...
Definition: classifier_predict_types.h:168
daal::algorithms::multi_class_classifier::prediction::interface1::BatchContainer
Provides methods to run implementations of the multi-class classifier prediction algorithm.
Definition: multi_class_classifier_predict.h:66
daal::algorithms::multi_class_classifier::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: multi_class_classifier_predict.h:304
daal::algorithms::multi_class_classifier::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::multi_class_classifier::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::multi_class_classifier::prediction::interface1::Batch
Provides methods to run implementations of the multi-class classifier prediction algorithm.
Definition: multi_class_classifier_predict.h:107
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::multi_class_classifier::prediction::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::multi_class_classifier::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::multi_class_classifier::prediction::interface2::Batch::input
InputType input
Definition: multi_class_classifier_predict.h:265
daal::algorithms::multi_class_classifier::prediction::interface2::Batch::parameter
ParameterType parameter
Definition: multi_class_classifier_predict.h:266
daal::algorithms::multi_class_classifier::prediction::interface2::BatchContainer
Provides methods to run implementations of the multi-class classifier prediction algorithm.
Definition: multi_class_classifier_predict.h:215
daal::algorithms::multi_class_classifier::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::classifier::prediction::interface1::Batch
Base class for making predictions based on the model of the classification algorithms.
Definition: classifier_predict.h:61
daal::algorithms::multi_class_classifier::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, pmethod, tmethod > > clone() const
Definition: multi_class_classifier_predict.h:168
daal::algorithms::multi_class_classifier::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: multi_class_classifier_predict.h:161

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