🎯 K-Nearest Neighbors Visualizer
← Back to Home

🎯 K-Nearest Neighbors (KNN)

Add training points and classify test points by finding nearest neighbors!

📚 What is K-Nearest Neighbors?

KNN is a simple yet powerful classification algorithm that predicts a point's class based on its K nearest neighbors. It's called "lazy learning" because it doesn't build a model during training.

How it works:

  • Store all training data points with their labels
  • When predicting, find the K closest points to the test point
  • Use majority voting among those K neighbors
  • Assign the most common class to the test point

Real-world applications:

  • Recommendation systems (Netflix, Amazon)
  • Image recognition and classification
  • Credit rating prediction
  • Pattern recognition in medical diagnosis

🎮 Controls

Add Training Points (Blue)
3
Class 1 (Training)
Class 2 (Training)
Class 3 (Training)
⭐ Test Point
Prediction
-