ClassesClasses | | Operators

create_class_knnT_create_class_knnCreateClassKnnCreateClassKnn (Operator)


create_class_knnT_create_class_knnCreateClassKnnCreateClassKnn — Create a k-nearest neighbors (k-NN) classifier.


create_class_knn( : : NumDim : KNNHandle)

Herror T_create_class_knn(const Htuple NumDim, Htuple* KNNHandle)

void CreateClassKnn(const HTuple& NumDim, HTuple* KNNHandle)

void HClassKnn::HClassKnn(const HTuple& NumDim)

void HClassKnn::CreateClassKnn(const HTuple& NumDim)

static void HOperatorSet.CreateClassKnn(HTuple numDim, out HTuple KNNHandle)

public HClassKnn(HTuple numDim)

void HClassKnn.CreateClassKnn(HTuple numDim)


create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnn creates a k-nearest neighbors (k-NN) data structure. This can be either used to classify data or to approximately locate nearest neighbors in a NumDimNumDimNumDimNumDimnumDim-dimensional space.

Most of the operators described in Classification/K-Nearest-Neighbor use the resulting handle KNNHandleKNNHandleKNNHandleKNNHandleKNNHandle.

The k-NN classifies by searching approximately the nearest neighbors and returning their classes as result. With the used approximation, the search time is logarithmically to the number of samples and dimensions.

The dimension of the feature vectors is the only parameter that necessarily has to be set in NumDimNumDimNumDimNumDimnumDim.

Execution Information

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.


NumDimNumDimNumDimNumDimnumDim (input_control)  number-array HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Number of dimensions of the feature.

Default value: 10

KNNHandleKNNHandleKNNHandleKNNHandleKNNHandle (output_control)  class_knn HClassKnn, HTupleHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Handle of the k-NN classifier.


If the parameters are valid, the operator create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnn returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Possible Successors

add_sample_class_knnadd_sample_class_knnAddSampleClassKnnAddSampleClassKnnAddSampleClassKnn, train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnn


create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvm, create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlp

See also

select_feature_set_knnselect_feature_set_knnSelectFeatureSetKnnSelectFeatureSetKnnSelectFeatureSetKnn, read_class_knnread_class_knnReadClassKnnReadClassKnnReadClassKnn


Marius Muja, David G. Lowe: “Fast Approximate Nearest Neighbors with Automatic Algorithm Configuration”; International Conference on Computer Vision Theory and Applications (VISAPP 09); 2009.



ClassesClasses | | Operators