k-nearest neighbors

Also: k-NN, KNN, kNN, k-nearest neighbours, nearest neighbor classifier

A non-parametric, “lazy” method: training just stores the data, and prediction finds the k nearest training points under a distance metric such as Euclidean distance. Small k overfits, large k underfits, and features must be on comparable scales.

Example

With k = 5, a query point whose five nearest neighbors are 3 blue and 2 red is classified blue; for regression it would predict the mean of their five values.

See it in the lesson: K-Nearest Neighbors →

Related terms

More in Classical ML