The Complete SPRLIB & ANNLIB

knn_classify

- classify a new pattern using the k-nearest neighbour classifier

SYNOPSIS

int knn_classify (k, class, pattern)

ARGUMENTS

int k The number of neighbours to be taken into account.
int class The classlabel to be taken into account.
double *pattern The pattern around which the k nearest neighbours have to be calculated, a vector of size [1..n].

RETURNS

The number of neighbours among the k nearest neighbours that have a classlabel equal to class.

FUNCTION

This function classifies a (new) pattern using the k-nearest neighbour rule. It takes as input k, the number of neighbours to be examined, the input pattern and class, which indicates the class to be looked at. The function returns the number of the k neighbours around the input pattern that have a classlabel equal to class. The function knn_init must have been called in advance otherwise this function will not work.

NOTE

The function knn_init must have been called for this function to work. Variable pattern is in vector format.

This document was generated using api2html on Thu Mar 5 09:00:00 MET DST 1998