Skip to content
Machine Learning

Is KNN a clustering algorithm?

No. It is a supervised learning method that could be used for classification and regression problems.

datasciencetrivia.com

Card 1 of 259. Answer: No. It is a supervised learning method that could be used for classification and regression problems.

Created by santiviquez

About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.

The longer answer

No. KNN, k-nearest neighbors, is a supervised learning algorithm for classification and regression. It needs labeled training data and predicts a new point's label from the labels of its k closest neighbors. Clustering is unsupervised: it groups unlabeled data.

The confusion comes from k-means, which is a clustering algorithm and also has a k and also uses distances. In KNN, k is the number of neighbors that vote on a prediction. In k-means, k is the number of clusters to find, and there are no labels at all.

KNN is also a lazy learner: it does no training beyond storing the data and does all its work at prediction time, which makes it slow on large datasets. Because it relies on distances, features need scaling, and it degrades in high dimensions where nearest neighbors stop being meaningfully near.

All questions