Interactive Tool

K-NN Classifier

Classify data points using K-Nearest Neighbors with average distance calculation.

Configuration

Add Training Point

Scatter Plot

?
A
B
C

Training Data (12 points)

IDXYClassAction
123A
232A
334A
453A
578B
687B
789B
898B
947C
1058C
1138C
1249C

How it Works

1. Calculate Distances

Compute Euclidean distance from test point to all training points:

d = √((x₂-x₁)² + (y₂-y₁)²)

2. Find K Nearest Neighbors

Sort distances and select the K closest points.

3. Calculate Average Distance per Class

For each class among the K neighbors, compute the average distance.

4. Classify

Assign the test point to the class with the minimum average distance.