The Complete SPRLIB & ANNLIB

knn_majority

- assign a classlabel according to the k-nearest neighbour rule

SYNOPSIS

int knn_majority (k, pattern)

ARGUMENTS

int k The number of neighbours to be taken into account.
double *pattern The pattern to be classified, a vector of size [1..n].

RETURNS

The function returns the classlabel of pattern according to the k nearest neighbours.

FUNCTION

This function assigns a classlabel to pattern according to the nearest neighbour rule. Around the pattern its k nearest neighbours are determined, of these k nearest neighbours the classlabels are calculated. The classlabel which will be assigned to pattern is the one which occurs the most in the k neighbours. The function knn_init must have been called in advance. This function differs from knn_classify since that function only counts the classlabel occurence, whereas this function assigns a label.

NOTE

In order to let this function work well, knn_init has to be called in advance to allocate the necessary structures. The variable pattern is in vector format.

SEE ALSO

knn_classify

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