Sources:
KNN (Towards Data Science)arrow-up-right
KNN Classification using Scikit-learn (Avinash Navlani)arrow-up-right
Is an instance-based algorithm. So, there is not training step. Classification is directly inferred!
For every unlabeled instance (the ones to be classified):
It measures the distance to every labeled sample.
It sorts the distances incrementally.
It selects the closets k instances.
It assigns the most frequent class on the selected k instances.
Last updated 6 years ago