Home   >   User Resources   >   Online Help   >   apakNearestNeighbour.Classifier
 

 

Function index Version 3.0.0

apakNearestNeighbour.Classifier(k, KnownData, KnownCategoryLabels, UnknownData)

Excel=apakNearestNeighbour.Classifier(k, KnownData, KnownCategoryLabels, UnknownData)

Result

Classifies unknown data with the k-nearest neighbors (kNN) algorithm: each unknown data point receives the category label held by the majority of its k nearest known data points (Euclidean distance). Returns a 1 x m vector of category labels.

Syntax

k: number of nearest neighbors to consider, between 1 and the number of known data points c

KnownData: r x c data matrix of known (labelled) data

KnownCategoryLabels: 1 x c (or c x 1) vector of category labels of the known data

UnknownData: r x m data matrix of unknown data to classify

Remarks

If several categories receive the same number of votes, the category of the nearest of the tied neighbors is chosen. With two categories, an odd k avoids ties. Ties in distance are broken by the lower column index of the known data.

Pressing Esc aborts the calculation; the function then returns "Calculation aborted by user."