classify_class_knnT_classify_class_knnClassifyClassKnnClassifyClassKnn (Operator)

Name

classify_class_knnT_classify_class_knnClassifyClassKnnClassifyClassKnn — Search for the next neighbors for a given feature vector.

Signature

classify_class_knn( : : KNNHandle, Features : Result, Rating)

Herror T_classify_class_knn(const Htuple KNNHandle, const Htuple Features, Htuple* Result, Htuple* Rating)

void ClassifyClassKnn(const HTuple& KNNHandle, const HTuple& Features, HTuple* Result, HTuple* Rating)

HTuple HClassKnn::ClassifyClassKnn(const HTuple& Features, HTuple* Rating) const

static void HOperatorSet.ClassifyClassKnn(HTuple KNNHandle, HTuple features, out HTuple result, out HTuple rating)

HTuple HClassKnn.ClassifyClassKnn(HTuple features, out HTuple rating)

Description

classify_class_knnclassify_class_knnClassifyClassKnnClassifyClassKnnClassifyClassKnn searches for the next 'k'"k""k""k""k" neighbors of the feature vector given in FeaturesFeaturesFeaturesFeaturesfeatures. The distance which is used to determine the next neighbor is the L2-norm of the given vector and the trainings samples.

The value of 'k'"k""k""k""k" can be set via set_params_class_knnset_params_class_knnSetParamsClassKnnSetParamsClassKnnSetParamsClassKnn. The results can either be the determined class of the feature vector or the indices of the nearest neighbors. The selection of the result behavior can be made by set_params_class_knnset_params_class_knnSetParamsClassKnnSetParamsClassKnnSetParamsClassKnn via the generic parameters 'method'"method""method""method""method" and 'max_num_classes'"max_num_classes""max_num_classes""max_num_classes""max_num_classes":

'classes_distance'"classes_distance""classes_distance""classes_distance""classes_distance":

returns the nearest samples for each of maximally 'max_num_classes'"max_num_classes""max_num_classes""max_num_classes""max_num_classes" different classes, if they have a representative in the nearest 'k'"k""k""k""k" neighbors. The results in ResultResultResultResultresult are classes sorted by their minimal distance in RatingRatingRatingRatingrating. There is no efficient way to determine in a k-NN-tree the nearest neighbor for exactly 'max_num_classes'"max_num_classes""max_num_classes""max_num_classes""max_num_classes" classes.

'classes_frequency'"classes_frequency""classes_frequency""classes_frequency""classes_frequency":

counts the occurrences of certain classes among the nearest 'k'"k""k""k""k" neighbors and returns the occurrent classes in ResultResultResultResultresult sorted by their relative frequency that is returned in RatingRatingRatingRatingrating. Again, maximally 'max_num_classes'"max_num_classes""max_num_classes""max_num_classes""max_num_classes" values are returned.

'classes_weighted_frequencies'"classes_weighted_frequencies""classes_weighted_frequencies""classes_weighted_frequencies""classes_weighted_frequencies":

counts the occurrences of certain classes among the nearest 'k'"k""k""k""k" neighbors and returns the occurrent classes in ResultResultResultResultresult sorted by their relative frequency weighted with the average distance that is returned in RatingRatingRatingRatingrating. Again, maximally 'max_num_classes'"max_num_classes""max_num_classes""max_num_classes""max_num_classes" values are returned.

'neighbors_distance'"neighbors_distance""neighbors_distance""neighbors_distance""neighbors_distance":

returns the indices of the nearest 'k'"k""k""k""k" neighbors in ResultResultResultResultresult and the distances in RatingRatingRatingRatingrating.

The default behavior is 'classes_distance'"classes_distance""classes_distance""classes_distance""classes_distance" and returns the classes and distances.

Execution Information

Parameters

KNNHandleKNNHandleKNNHandleKNNHandleKNNHandle (input_control)  class_knn HClassKnn, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the k-NN classifier.

FeaturesFeaturesFeaturesFeaturesfeatures (input_control)  number-array HTupleHTupleHtuple (real) (double) (double) (double)

Features that should be classified.

ResultResultResultResultresult (output_control)  number-array HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

The classification result, either class IDs or sample indices.

RatingRatingRatingRatingrating (output_control)  number-array HTupleHTupleHtuple (real) (double) (double) (double)

A rating for the results. This value contains either a distance, a frequency or a weighted frequency.

Result

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

Possible Predecessors

train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnn, read_class_knnread_class_knnReadClassKnnReadClassKnnReadClassKnn, set_params_class_knnset_params_class_knnSetParamsClassKnnSetParamsClassKnnSetParamsClassKnn

Possible Successors

clear_class_knnclear_class_knnClearClassKnnClearClassKnnClearClassKnn

See also

create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnn, read_class_knnread_class_knnReadClassKnnReadClassKnnReadClassKnn

References

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

Module

Foundation