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

kdtree_knn_classification_model.h
1 /* file: kdtree_knn_classification_model.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 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 class defining the K-Nearest Neighbors (kNN) classification model
45 //--
46 */
47 
48 #ifndef __KDTREE_KNN_CLASSIFICATION_MODEL_H__
49 #define __KDTREE_KNN_CLASSIFICATION_MODEL_H__
50 
51 #include "algorithms/classifier/classifier_model.h"
52 #include "data_management/data/aos_numeric_table.h"
53 #include "data_management/data/soa_numeric_table.h"
54 #include "data_management/data/homogen_numeric_table.h"
55 #include "algorithms/engines/mt19937/mt19937.h"
56 
57 using namespace daal::services;
58 
59 namespace daal
60 {
61 namespace algorithms
62 {
63 
74 namespace kdtree_knn_classification
75 {
76 
81 enum DataUseInModel
82 {
83  doNotUse = 0,
84  doUse = 1
85 };
86 
90 namespace interface1
91 {
92 
99 /* [Parameter source code] */
100 struct DAAL_EXPORT Parameter : public daal::algorithms::classifier::Parameter
101 {
109  Parameter(size_t nClasses = 2, size_t nNeighbors = 1, int randomSeed = 777, DataUseInModel dataUse = doNotUse)
110  : daal::algorithms::classifier::Parameter(nClasses),
111  k(nNeighbors),
112  seed(randomSeed),
113  dataUseInModel(dataUse),
114  engine(engines::mt19937::Batch<>::create())
115  {}
116 
120  services::Status check() const DAAL_C11_OVERRIDE;
121 
122  size_t k;
123  int seed;
124  DataUseInModel dataUseInModel;
125  engines::EnginePtr engine;
126 };
127 /* [Parameter source code] */
128 
140 class DAAL_EXPORT Model : public daal::algorithms::classifier::Model
141 {
142 public:
143  DECLARE_MODEL_IFACE(Model, classifier::Model);
149  Model(size_t nFeatures = 0);
150 
156  static services::SharedPtr<Model> create(size_t nFeatures = 0, services::Status *stat = NULL);
157 
158  virtual ~Model();
159 
160 
161  class ModelImpl;
162 
167  const ModelImpl *impl() const { return _impl; }
168 
173  ModelImpl *impl() { return _impl; }
174 
179  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
180 
181 protected:
182  Model(size_t nFeatures, services::Status &st);
183 
184  services::Status serializeImpl(data_management::InputDataArchive *arch) DAAL_C11_OVERRIDE;
185 
186  services::Status deserializeImpl(const data_management::OutputDataArchive *arch) DAAL_C11_OVERRIDE;
187 
188 private:
189  ModelImpl *_impl;
190 };
191 typedef services::SharedPtr<Model> ModelPtr;
192 } // namespace interface1
193 
194 using interface1::Parameter;
195 using interface1::Model;
196 using interface1::ModelPtr;
197 
198 } // namespace kdtree_knn_classification
199 
201 } // namespace algorithms
202 } // namespace daal
203 
204 #endif
daal::algorithms::kdtree_knn_classification::interface1::Parameter
KD-tree based kNN algorithm parameters.
Definition: kdtree_knn_classification_model.h:100
daal
Definition: algorithm_base_common.h:57
daal::algorithms::kdtree_knn_classification::doNotUse
Definition: kdtree_knn_classification_model.h:83
daal::algorithms::kdtree_knn_classification::doUse
Definition: kdtree_knn_classification_model.h:84
daal::algorithms::kdtree_knn_classification::DataUseInModel
DataUseInModel
The option to enable/disable an usage of the input dataset in kNN model.
Definition: kdtree_knn_classification_model.h:81
daal::algorithms::kdtree_knn_classification::interface1::Model
Base class for models trained with the KD-tree based kNN algorithm
Definition: kdtree_knn_classification_model.h:140
daal::algorithms::kdtree_knn_classification::interface1::Model::impl
const ModelImpl * impl() const
Definition: kdtree_knn_classification_model.h:167
daal::algorithms::kdtree_knn_classification::interface1::Parameter::Parameter
Parameter(size_t nClasses=2, size_t nNeighbors=1, int randomSeed=777, DataUseInModel dataUse=doNotUse)
Definition: kdtree_knn_classification_model.h:109
daal::algorithms::kdtree_knn_classification::interface1::Model::impl
ModelImpl * impl()
Definition: kdtree_knn_classification_model.h:173
daal::services
Contains classes that implement service functionality, including error handling, memory allocation...
Definition: collection.h:51

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