First page Back Continue Last page Overview Graphics
k-Nearest-Neighbor Mathematically
The k-Nearest-Neighbor Classifier (k-NN) works directly on the learned samples, instead of creating rules compared to other classification methods.
- Given a set of categories c1, c2, ... cn, also called classes, e.g. {"male", "female"}. There is also a learnset LS consisting of labelled instances.
- The task of classification consists in assigning a category or class to an arbitrary instance. If the instance o is an element of LS, the label of the instance will be used.
- If o is not in LS:
o is compared with all instances of LS. A distance metric is used for comparison.
We determine the k closest neighbors of o, i.e. the items with the smallest distances.
k is a user defined constant and a positive integer, which is usually small.
- The most common class of LS will be assigned to the instance o.
If k = 1, then the object is simply assigned to the class of that single nearest neighbor.
k-NN is a type of instance-based learning, or lazy learning, where the function is only approximated locally and all the computations are performed, when we do the actual classification.