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

kdtree_knn_classification_predict.h
1 /* file: kdtree_knn_classification_predict.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the interface for K-Nearest Neighbors (kNN) model-based prediction
45 //--
46 */
47 
48 #ifndef __KDTREE_KNN_CLASSIFICATION_PREDICT_H__
49 #define __KDTREE_KNN_CLASSIFICATION_PREDICT_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_predict_types.h"
53 #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_model.h"
54 #include "algorithms/classifier/classifier_predict.h"
55 #include "data_management/data/homogen_numeric_table.h"
56 
57 namespace daal
58 {
59 namespace algorithms
60 {
61 namespace kdtree_knn_classification
62 {
63 namespace prediction
64 {
65 namespace interface1
66 {
77 template<typename algorithmFPType, Method method, CpuType cpu>
78 class DAAL_EXPORT BatchContainer : public PredictionContainerIface
79 {
80 public:
85  BatchContainer(daal::services::Environment::env *daalEnv);
86 
87  ~BatchContainer();
88 
92  services::Status compute() DAAL_C11_OVERRIDE;
93 };
94 
111 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
112 class Batch : public classifier::prediction::Batch
113 {
114 public:
115  typedef classifier::prediction::Batch super;
116 
117  typedef algorithms::kdtree_knn_classification::prediction::Input InputType;
118  typedef algorithms::kdtree_knn_classification::Parameter ParameterType;
119  typedef typename super::ResultType ResultType;
120 
121  InputType input;
122  ParameterType parameter;
125  Batch()
126  {
127  initialize();
128  }
129 
136  Batch(const Batch<algorithmFPType, method> & other) : classifier::prediction::Batch(other), input(other.input), parameter(other.parameter)
137  {
138  initialize();
139  }
140 
145  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
146 
151  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
152 
158  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
159  {
160  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
161  }
162 
163 protected:
164  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
165  {
166  return new Batch<algorithmFPType, method>(*this);
167  }
168 
169  services::Status allocateResult() DAAL_C11_OVERRIDE
170  {
171  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
172  _res = _result.get();
173  return s;
174  }
175 
176  void initialize()
177  {
178  _in = &input;
179  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
180  _par = &parameter;
181  }
182 };
183 
185 } // namespace interface1
186 
187 using interface1::BatchContainer;
188 using interface1::Batch;
189 
190 } // namespace prediction
191 } // namespace kdtree_knn_classification
192 } // namespace algorithms
193 } // namespace daal
194 
195 #endif
daal::algorithms::kdtree_knn_classification::interface1::Parameter
KD-tree based kNN algorithm parameters.
Definition: kdtree_knn_classification_model.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:190
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:78
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:81
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_predict.h:145
daal::algorithms::classifier::prediction::interface1::Input
Input objects in the prediction stage of the classification algorithm.
Definition: classifier_predict_types.h:133
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:79
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::Batch
Batch()
Definition: kdtree_knn_classification_predict.h:125
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:66
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: kdtree_knn_classification_predict.h:158
daal::algorithms::classifier::prediction::interface1::Batch
Base class for making predictions based on the model of the classification algorithms.
Definition: classifier_predict.h:85
daal::batch
Definition: daal_defines.h:132
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: kdtree_knn_classification_predict.h:122
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::input
InputType input
Definition: kdtree_knn_classification_predict.h:121
daal::algorithms::kdtree_knn_classification::prediction::interface1::Input
Provides an interface for input objects for making KD-tree based kNN model-based prediction.
Definition: kdtree_knn_classification_predict_types.h:98
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:112
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_predict.h:151
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: kdtree_knn_classification_predict.h:136

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