C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 5

kdtree_knn_classification_predict.h
1 /* file: kdtree_knn_classification_predict.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for K-Nearest Neighbors (kNN) model-based prediction
19 //--
20 */
21 
22 #ifndef __KDTREE_KNN_CLASSIFICATION_PREDICT_H__
23 #define __KDTREE_KNN_CLASSIFICATION_PREDICT_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_predict_types.h"
27 #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_model.h"
28 #include "algorithms/classifier/classifier_predict.h"
29 #include "data_management/data/homogen_numeric_table.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace kdtree_knn_classification
36 {
37 namespace prediction
38 {
39 namespace interface1
40 {
51 template<typename algorithmFPType, Method method, CpuType cpu>
52 class DAAL_EXPORT BatchContainer : public PredictionContainerIface
53 {
54 public:
59  BatchContainer(daal::services::Environment::env *daalEnv);
60 
61  ~BatchContainer();
62 
66  services::Status compute() DAAL_C11_OVERRIDE;
67 };
68 
85 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
86 class Batch : public classifier::prediction::Batch
87 {
88 public:
89  typedef classifier::prediction::Batch super;
90 
91  typedef algorithms::kdtree_knn_classification::prediction::Input InputType;
92  typedef algorithms::kdtree_knn_classification::Parameter ParameterType;
93  typedef typename super::ResultType ResultType;
94 
95  InputType input;
96  ParameterType parameter;
99  Batch()
100  {
101  initialize();
102  }
103 
110  Batch(const Batch<algorithmFPType, method> & other) : classifier::prediction::Batch(other), input(other.input), parameter(other.parameter)
111  {
112  initialize();
113  }
114 
119  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
120 
125  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
126 
132  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
133  {
134  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
135  }
136 
137 protected:
138  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
139  {
140  return new Batch<algorithmFPType, method>(*this);
141  }
142 
143  services::Status allocateResult() DAAL_C11_OVERRIDE
144  {
145  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
146  _res = _result.get();
147  return s;
148  }
149 
150  void initialize()
151  {
152  _in = &input;
153  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
154  _par = &parameter;
155  }
156 };
157 
159 } // namespace interface1
160 
161 using interface1::BatchContainer;
162 using interface1::Batch;
163 
164 } // namespace prediction
165 } // namespace kdtree_knn_classification
166 } // namespace algorithms
167 } // namespace daal
168 
169 #endif
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:52
daal
Definition: algorithm_base_common.h:31
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_predict.h:119
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::Batch
Batch()
Definition: kdtree_knn_classification_predict.h:99
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:40
daal::batch
Definition: daal_defines.h:110
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: kdtree_knn_classification_predict.h:96
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: kdtree_knn_classification_predict.h:132
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::input
InputType input
Definition: kdtree_knn_classification_predict.h:95
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:86
daal::algorithms::classifier::prediction::prediction
Definition: classifier_predict_types.h:76
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_predict.h:125
daal::algorithms::kdtree_knn_classification::prediction::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: kdtree_knn_classification_predict.h:110

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