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

kdtree_knn_classification_predict.h
1 /* file: kdtree_knn_classification_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 K-Nearest Neighbors (kNN) model-based prediction
21 //--
22 */
23 
24 #ifndef __KDTREE_KNN_CLASSIFICATION_PREDICT_H__
25 #define __KDTREE_KNN_CLASSIFICATION_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_predict_types.h"
29 #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_model.h"
30 #include "algorithms/classifier/classifier_predict.h"
31 #include "data_management/data/homogen_numeric_table.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace kdtree_knn_classification
38 {
39 namespace prediction
40 {
41 namespace interface1
42 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class BatchContainer : public PredictionContainerIface
55 {
56 public:
61  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
62 
63  DAAL_DEPRECATED ~BatchContainer();
64 
68  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
69 };
70 
87 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
88 class Batch : public classifier::prediction::interface1::Batch
89 {
90 public:
91  typedef classifier::prediction::interface1::Batch super;
92 
93  typedef algorithms::kdtree_knn_classification::prediction::Input InputType;
94  typedef algorithms::kdtree_knn_classification::interface1::Parameter ParameterType;
95  typedef typename super::ResultType ResultType;
96 
97  InputType input;
98  ParameterType parameter;
101  DAAL_DEPRECATED Batch()
102  {
103  initialize();
104  }
105 
112  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> & other) : classifier::prediction::interface1::Batch(other), input(other.input), parameter(other.parameter)
113  {
114  initialize();
115  }
116 
121  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
122 
127  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
128 
134  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
135  {
136  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
137  }
138 
139 protected:
140  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
141  {
142  return new Batch<algorithmFPType, method>(*this);
143  }
144 
145  services::Status allocateResult() DAAL_C11_OVERRIDE
146  {
147  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
148  _res = _result.get();
149  return s;
150  }
151 
152  void initialize()
153  {
154  _in = &input;
155  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
156  _par = &parameter;
157  }
158 };
159 
161 } // namespace interface1
162 
163 namespace interface2
164 {
175 template<typename algorithmFPType, Method method, CpuType cpu>
176 class BatchContainer : public PredictionContainerIface
177 {
178 public:
183  BatchContainer(daal::services::Environment::env *daalEnv);
184 
185  ~BatchContainer();
186 
190  services::Status compute() DAAL_C11_OVERRIDE;
191 };
192 
209 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
210 class Batch : public classifier::prediction::Batch
211 {
212 public:
213  typedef classifier::prediction::Batch super;
214 
215  typedef algorithms::kdtree_knn_classification::prediction::Input InputType;
216  typedef algorithms::kdtree_knn_classification::Parameter ParameterType;
217  typedef typename super::ResultType ResultType;
218 
219  InputType input;
220  ParameterType parameter;
223  Batch()
224  {
225  initialize();
226  }
227 
234  Batch(const Batch<algorithmFPType, method> & other) : classifier::prediction::Batch(other), input(other.input), parameter(other.parameter)
235  {
236  initialize();
237  }
238 
243  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
244 
249  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
250 
256  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
257  {
258  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
259  }
260 
261 protected:
262  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
263  {
264  return new Batch<algorithmFPType, method>(*this);
265  }
266 
267  services::Status allocateResult() DAAL_C11_OVERRIDE
268  {
269  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
270  _res = _result.get();
271  return s;
272  }
273 
274  void initialize()
275  {
276  _in = &input;
277  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
278  _par = &parameter;
279  }
280 };
281 
283 } // namespace interface2
284 
285 using interface2::BatchContainer;
286 using interface2::Batch;
287 
288 } // namespace prediction
289 } // namespace kdtree_knn_classification
290 } // namespace algorithms
291 } // namespace daal
292 
293 #endif
daal::algorithms::kdtree_knn_classification::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_predict.h:243
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_predict.h:127
daal::batch
Definition: daal_defines.h:112
daal::algorithms::kdtree_knn_classification::prediction::interface2::Batch
Provides methods to run implementations of the KD-tree based kNN model-based prediction.
Definition: kdtree_knn_classification_predict.h:210
daal::algorithms::kdtree_knn_classification::prediction::interface2::Batch::parameter
ParameterType parameter
Definition: kdtree_knn_classification_predict.h:220
daal::algorithms::kdtree_knn_classification::interface1::Parameter
KD-tree based kNN algorithm parameters.
Definition: kdtree_knn_classification_model.h:74
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::kdtree_knn_classification::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::kdtree_knn_classification::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::kdtree_knn_classification::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: kdtree_knn_classification_predict.h:112
daal::algorithms::classifier::prediction::interface1::Input
Input objects in the prediction stage of the classification algorithm.
Definition: classifier_predict_types.h:111
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch()
Definition: kdtree_knn_classification_predict.h:101
daal::algorithms::kdtree_knn_classification::prediction::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: kdtree_knn_classification_predict.h:234
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: kdtree_knn_classification_predict.h:98
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::kdtree_knn_classification::prediction::interface1::Batch::input
InputType input
Definition: kdtree_knn_classification_predict.h:97
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_predict.h:121
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::kdtree_knn_classification::prediction::interface2::BatchContainer
Class containing computation methods for KD-tree based kNN model-based prediction.
Definition: kdtree_knn_classification_predict.h:176
daal::algorithms::kdtree_knn_classification::prediction::interface2::Batch::input
InputType input
Definition: kdtree_knn_classification_predict.h:219
daal::algorithms::kdtree_knn_classification::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::kdtree_knn_classification::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: kdtree_knn_classification_predict.h:256
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: kdtree_knn_classification_predict.h:134
daal::algorithms::kdtree_knn_classification::prediction::interface1::BatchContainer
Class containing computation methods for KD-tree based kNN model-based prediction.
Definition: kdtree_knn_classification_predict.h:54
daal::algorithms::kdtree_knn_classification::prediction::interface2::Batch::Batch
Batch()
Definition: kdtree_knn_classification_predict.h:223
daal::algorithms::kdtree_knn_classification::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_predict.h:249
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::kdtree_knn_classification::prediction::interface1::Batch
Provides methods to run implementations of the KD-tree based kNN model-based prediction.
Definition: kdtree_knn_classification_predict.h:88

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