↓ Skip to main content

KNN

·136 words·1 min
Dave the human
Author
Dave the human
Homo sapiens in the loop
Table of Contents

K nearest neighbours is a supervised learning algorithm that, given a data point to predict onto, uses euclidean distance to calculate the distance between that point and the training data to make a prediction based on the closest $k$ points ($k$ is then an hyperparameter defined by the user a-priori).
In case of a classification task, it will assign a label with majority voting; in case of a regression task it will compute the average of those closest points’ value.

It is called a lazy learner because it actually does not perform any training and it is immediately ready for inference.

Pitfalls
#

Data scaling like normalization or standardization is recommended since euclidean distance is highly sensitive to the scale of the axis, and a dimension much larger than the other would dominate the distance calculation.


Comments