Challenges
k-NN: classification with nearest neighbours
Artificial Intelligence
Medium
k-NN algorithm
Solves: 6
k-NN: classification with nearest neighbours
Author: CyberSamSU
Points
30
k-NN (k-nearest neighbors) is the simplest classification algorithm: to classify a new point, the k nearest training points to it are found, then the class with the majority vote among them is chosen. Distance is usually measured using Euclidean distance:
masofa(p, q) = sqrt((p.x - q.x)^2 + (p.y - q.y)^2)
Training data (features: weight-index, activity-index):
| x | y | class |
|---|---|---|
4 | 9 | IT |
1 | 10 | IT |
1 | 5 | IT |
2 | 10 | MUSHUK |
9 | 7 | MUSHUK |
6 | 5 | MUSHUK |
New point (to be classified): (7, 6).
When k = 3 (i.e. based on the 3 nearest neighbors), what class is this point predicted to belong to?
Answer: IT or MUSHUK (case-insensitive).
To submit a flag, log in.