What is k-Nearest Neighbors (KNN) and how does it make predictions?
Updated May 17, 2026
Short answer
KNN predicts labels based on the majority class of nearest data points.
Deep explanation
KNN is a lazy learning algorithm that stores training data and predicts based on distance metrics like Euclidean distance. It finds k closest points and uses majority voting (classification) or averaging (regression). It has no explicit training phase.
Real-world example
Recommendation systems suggesting similar products based on user behavior.
Common mistakes
- Not scaling features before using distance-based algorithms.
Follow-up questions
- How do you choose k?
- Why is KNN slow?