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

kdtree_knn_classification_model.h
1 /* file: kdtree_knn_classification_model.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 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/mcg59/mcg59.h"
56 
57 namespace daal
58 {
59 namespace algorithms
60 {
61 
72 namespace kdtree_knn_classification
73 {
74 
79 enum DataUseInModel
80 {
81  doNotUse = 0,
82  doUse = 1
83 };
84 
88 namespace interface1
89 {
90 
97 /* [Parameter source code] */
98 struct DAAL_EXPORT Parameter : public daal::algorithms::classifier::Parameter
99 {
107  Parameter(size_t nClasses = 2, size_t nNeighbors = 1, int randomSeed = 777, DataUseInModel dataUse = doNotUse)
108  : daal::algorithms::classifier::Parameter(nClasses),
109  k(nNeighbors),
110  seed(randomSeed),
111  dataUseInModel(dataUse),
112  engine(engines::mcg59::Batch<>::create())
113  {}
114 
118  services::Status check() const DAAL_C11_OVERRIDE;
119 
120  size_t k;
121  int seed;
122  DataUseInModel dataUseInModel;
123  engines::EnginePtr engine;
124 };
125 /* [Parameter source code] */
126 
138 class DAAL_EXPORT Model : public daal::algorithms::classifier::Model
139 {
140 public:
141  DECLARE_MODEL_IFACE(Model, classifier::Model);
147  Model(size_t nFeatures = 0);
148 
154  static services::SharedPtr<Model> create(size_t nFeatures = 0, services::Status *stat = NULL);
155 
156  virtual ~Model();
157 
158 
159  class ModelImpl;
160 
165  const ModelImpl *impl() const { return _impl; }
166 
171  ModelImpl *impl() { return _impl; }
172 
177  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
178 
179 protected:
180  Model(size_t nFeatures, services::Status &st);
181 
182  services::Status serializeImpl(data_management::InputDataArchive *arch) DAAL_C11_OVERRIDE;
183 
184  services::Status deserializeImpl(const data_management::OutputDataArchive *arch) DAAL_C11_OVERRIDE;
185 
186 private:
187  ModelImpl *_impl;
188 };
189 typedef services::SharedPtr<Model> ModelPtr;
190 } // namespace interface1
191 
192 using interface1::Parameter;
193 using interface1::Model;
194 using interface1::ModelPtr;
195 
196 } // namespace kdtree_knn_classification
197 
199 } // namespace algorithms
200 } // namespace daal
201 
202 #endif
daal::algorithms::kdtree_knn_classification::interface1::Parameter
KD-tree based kNN algorithm parameters.
Definition: kdtree_knn_classification_model.h:98
daal::algorithms::kdtree_knn_classification::doUse
Definition: kdtree_knn_classification_model.h:82
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::data_management::interface1::InputDataArchive
Provides methods to create an archive data object (serialized) and access this object.
Definition: data_archive.h:715
daal::algorithms::kdtree_knn_classification::doNotUse
Definition: kdtree_knn_classification_model.h:81
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:79
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::classifier::interface1::Model
Base class for the model of the classification algorithm.
Definition: classifier_model.h:95
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:138
daal::data_management::interface1::OutputDataArchive
Provides methods to restore an object from its serialized counterpart and access the restored object...
Definition: data_archive.h:978
daal::algorithms::kdtree_knn_classification::interface1::Model::impl
const ModelImpl * impl() const
Definition: kdtree_knn_classification_model.h:165
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:107
daal::algorithms::kdtree_knn_classification::interface1::Parameter::engine
engines::EnginePtr engine
Definition: kdtree_knn_classification_model.h:123
daal::algorithms::kdtree_knn_classification::interface1::Model::impl
ModelImpl * impl()
Definition: kdtree_knn_classification_model.h:171
daal::algorithms::kdtree_knn_classification::interface1::Parameter::dataUseInModel
DataUseInModel dataUseInModel
Definition: kdtree_knn_classification_model.h:122
daal::algorithms::kdtree_knn_classification::interface1::Parameter::seed
int seed
Definition: kdtree_knn_classification_model.h:121
daal::algorithms::kdtree_knn_classification::interface1::Parameter::k
size_t k
Definition: kdtree_knn_classification_model.h:120

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