How It Works
K-Nearest Neighbors (KNN) is a simple supervised machine learning algorithm used for classification and regression:
- When a new point needs to be classified, the algorithm finds the K closest training points
- It assigns the new point to the class that appears most frequently among its K nearest neighbors
- The distance between points is typically calculated using the Euclidean distance
- The choice of K affects the decision boundary smoothness - lower values create more complex boundaries
Interactive Features
- Add training points of different classes by clicking on the canvas
- Add test points to see how they get classified
- Adjust the K value to see how it affects classification
- Toggle the decision boundary visualization to see classification regions
- Generate random points to quickly test the algorithm