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

classifier_predict.h
1 /* file: 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 prediction stage of the classification algorithm interface.
21 //--
22 */
23 
24 #ifndef __CLASSIFIER_PREDICT_H__
25 #define __CLASSIFIER_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/classifier/classifier_predict_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace classifier
35 {
36 namespace prediction
37 {
38 
39 namespace interface1
40 {
61 class Batch : public daal::algorithms::Prediction
62 {
63 public:
64  typedef algorithms::classifier::prediction::interface1::Input InputType;
65  typedef algorithms::classifier::interface1::Parameter ParameterType;
66  typedef algorithms::classifier::prediction::interface1::Result ResultType;
67 
72  Batch()
73  {
74  initialize();
75  }
76 
84  Batch(const Batch &other)
85  {
86  initialize();
87  }
88 
89  virtual ~Batch() {}
90 
95  DAAL_DEPRECATED_VIRTUAL virtual InputType * getInput() = 0;
96 
101  DAAL_DEPRECATED interface1::ResultPtr getResult()
102  {
103  return _result;
104  }
105 
112  DAAL_DEPRECATED services::Status setResult(const interface1::ResultPtr &result)
113  {
114  DAAL_CHECK(result, services::ErrorNullResult)
115  _result = result;
116  _res = _result.get();
117  return services::Status();
118  }
119 
125  DAAL_DEPRECATED services::SharedPtr<Batch> clone() const
126  {
127  return services::SharedPtr<Batch>(cloneImpl());
128  }
129 
130 protected:
131 
132  void initialize()
133  {
134  _result.reset(new ResultType());
135  }
136  virtual Batch * cloneImpl() const DAAL_C11_OVERRIDE = 0;
137  interface1::ResultPtr _result;
138 };
140 } // namespace interface1
141 
142 namespace interface2
143 {
164 class Batch : public daal::algorithms::Prediction
165 {
166 public:
167  typedef algorithms::classifier::prediction::Input InputType;
168  typedef algorithms::classifier::Parameter ParameterType;
169  typedef algorithms::classifier::prediction::Result ResultType;
170 
171  Batch()
172  {
173  initialize();
174  }
175 
182  Batch(const Batch &other)
183  {
184  initialize();
185  }
186 
187  virtual ~Batch() {}
188 
194  virtual InputType * getInput() = 0;
199  ParameterType& parameter() { return *static_cast<ParameterType*>(this->getBaseParameter()); }
200 
205  // const ParameterType& parameter() const { return *static_cast<const ParameterType*>(this->getBaseParameter()); }
206 
211  ResultPtr getResult()
212  {
213  return _result;
214  }
215 
222  services::Status setResult(const ResultPtr &result)
223  {
224  DAAL_CHECK(result, services::ErrorNullResult)
225  _result = result;
226  _res = _result.get();
227  return services::Status();
228  }
229 
235  services::SharedPtr<Batch> clone() const
236  {
237  return services::SharedPtr<Batch>(cloneImpl());
238  }
239 
240 protected:
241 
242  void initialize()
243  {
244  _result.reset(new ResultType());
245  }
246  virtual Batch * cloneImpl() const DAAL_C11_OVERRIDE = 0;
247  ResultPtr _result;
248 };
250 } // namespace interface2
251 using interface2::Batch;
252 
253 }
254 }
255 }
256 }
257 #endif
daal::algorithms::classifier::prediction::interface1::Batch::setResult
DAAL_DEPRECATED services::Status setResult(const interface1::ResultPtr &result)
Definition: classifier_predict.h:112
daal::algorithms::classifier::prediction::interface1::Batch::Batch
Batch(const Batch &other)
Definition: classifier_predict.h:84
daal::algorithms::classifier::prediction::interface2::Batch::Batch
Batch(const Batch &other)
Definition: classifier_predict.h:182
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::classifier::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch > clone() const
Definition: classifier_predict.h:125
daal::algorithms::classifier::prediction::interface1::Batch::Batch
Batch()
Definition: classifier_predict.h:72
daal::algorithms::classifier::prediction::interface2::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: classifier_predict.h:222
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::classifier::prediction::interface1::Input
Input objects in the prediction stage of the classification algorithm.
Definition: classifier_predict_types.h:111
daal::algorithms::classifier::prediction::interface2::Batch::getResult
ResultPtr getResult()
Definition: classifier_predict.h:211
daal::algorithms::classifier::prediction::interface1::Batch::getResult
DAAL_DEPRECATED interface1::ResultPtr getResult()
Definition: classifier_predict.h:101
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::classifier::prediction::interface2::Batch::clone
services::SharedPtr< Batch > clone() const
Definition: classifier_predict.h:235
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::classifier::prediction::interface2::Batch
Base class for making predictions based on the model of the classification algorithms.
Definition: classifier_predict.h:164
daal::algorithms::classifier::prediction::interface2::Batch::parameter
ParameterType & parameter()
Definition: classifier_predict.h:199
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::Prediction
Provides prediction methods depending on the model such as linear_regression::Model. The methods of the class support different computation modes: batch, distributed, and online(see ComputeMode). Classes that implement specific algorithms of the model based data prediction are derived classes of the Prediction class. The class additionally provides virtual methods for validation of input and output parameters of the algorithms.
Definition: prediction.h:52
daal::algorithms::classifier::prediction::interface1::Batch::getInput
virtual DAAL_DEPRECATED_VIRTUAL InputType * getInput()=0

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