Classification Space
Controls
What is KNN?
K-Nearest Neighbors is a simple yet powerful classification algorithm. It classifies a point based on the majority class of its K nearest neighbors.
How to Use
- Click anywhere to classify that point
- Watch the algorithm find K nearest neighbors
- Adjust K to see how it affects classification
- Try different distance metrics
Custom Mode
Select "Custom" dataset to draw your own training points. Switch between Add/Delete modes to create your dataset.
Algorithm Steps
- Calculate distance from query to all training points
- Sort points by distance (ascending)
- Select K nearest neighbors
- Count votes for each class
- Assign majority class to query
Distance Metrics
- Euclidean: √(Σ(xᵢ - yᵢ)²)
- Manhattan: Σ|xᵢ - yᵢ|
- Chebyshev: max(|xᵢ - yᵢ|)
Weighted Voting
When enabled, closer neighbors have more influence.
Each vote is weighted by 1/distance.
K Nearest Neighbors
0
Click to classify a point
| K | Metric | Prediction | Confidence |
|---|---|---|---|
| Classify a point to compare | |||
Shows classification with different K values and metrics.