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

kdtree_knn_classification_training_batch.h
1 /* file: kdtree_knn_classification_training_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 Neighbor (kNN) model-based training in the batch processing mode
19 //--
20 */
21 
22 #ifndef __KDTREE_KNN_CLASSIFICATION_TRAINING_BATCH_H__
23 #define __KDTREE_KNN_CLASSIFICATION_TRAINING_BATCH_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_training_types.h"
27 #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_model.h"
28 #include "algorithms/classifier/classifier_training_batch.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace kdtree_knn_classification
35 {
36 namespace training
37 {
38 namespace interface1
39 {
50 template <typename algorithmFPType, Method method, CpuType cpu>
51 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
52 {
53 public:
58  BatchContainer(daal::services::Environment::env * daalEnv);
59 
61  ~BatchContainer();
62 
66  services::Status compute() DAAL_C11_OVERRIDE;
67 };
68 
84 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
85 class DAAL_EXPORT Batch : public classifier::training::Batch
86 {
87 public:
88  typedef classifier::training::Batch super;
89 
90  typedef typename super::InputType InputType;
91  typedef algorithms::kdtree_knn_classification::Parameter ParameterType;
92  typedef algorithms::kdtree_knn_classification::training::Result ResultType;
93 
94  ParameterType parameter;
95  InputType input;
98  Batch()
99  {
100  initialize();
101  }
102 
109  Batch(const Batch<algorithmFPType, method> & other) : classifier::training::Batch(other),
110  parameter(other.parameter), input(other.input)
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 
131  ResultPtr getResult() { return Result::cast(_result); }
132 
136  services::Status resetResult() DAAL_C11_OVERRIDE
137  {
138  _result.reset(new ResultType());
139  DAAL_CHECK(_result, services::ErrorNullResult);
140  _res = NULL;
141  return services::Status();
142  }
143 
150  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
151  {
152  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
153  }
154 
155 protected:
156  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
157  {
158  return new Batch<algorithmFPType, method>(*this);
159  }
160 
161  services::Status allocateResult() DAAL_C11_OVERRIDE
162  {
163  const ResultPtr res = getResult();
164  DAAL_CHECK(_result, services::ErrorNullResult);
165  services::Status s = res->template allocate<algorithmFPType>((classifier::training::InputIface *)(&input), &parameter, (int)method);
166  _res = _result.get();
167  return s;
168  }
169 
170  void initialize()
171  {
172  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
173  _in = &input;
174  _par = &parameter;
175  _result.reset(new ResultType());
176  }
177 };
178 
180 } // namespace interface1
181 
182 using interface1::BatchContainer;
183 using interface1::Batch;
184 
185 } // namespace training
186 } // namespace kdtree_knn_classification
187 } // namespace algorithms
188 } // namespace daal
189 
190 #endif
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: kdtree_knn_classification_training_batch.h:150
daal
Definition: algorithm_base_common.h:31
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::input
InputType input
Definition: kdtree_knn_classification_training_batch.h:95
daal::algorithms::kdtree_knn_classification::training::interface1::Batch
Provides methods for KD-tree based kNN model-based training in the batch processing mode...
Definition: kdtree_knn_classification_training_batch.h:85
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: kdtree_knn_classification_training_batch.h:131
daal::batch
Definition: daal_defines.h:106
daal::algorithms::kdtree_knn_classification::training::interface1::BatchContainer
Class containing methods for KD-tree based kNN model-based training using algorithmFPType precision a...
Definition: kdtree_knn_classification_training_batch.h:51
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::Batch
Batch()
Definition: kdtree_knn_classification_training_batch.h:98
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::parameter
ParameterType parameter
Definition: kdtree_knn_classification_training_batch.h:94
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_training_batch.h:119
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_training_batch.h:125
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: kdtree_knn_classification_training_batch.h:136
daal::algorithms::kdtree_knn_classification::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: kdtree_knn_classification_training_batch.h:109
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50

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