$ ./guess_the_languageAI & ML
AI & ML · medium · #9

With uniform voting, what does this k-NN classifier predict for the query point?

# distance to query point -> label
1.2 -> cat
0.4 -> dog
2.5 -> dog
0.9 -> cat
0.7 -> cat

knn = KNeighborsClassifier(n_neighbors=3)
  1. cat (2 of 3 votes)
  2. dog (nearest point)
  3. dog (2 of 3 votes)
  4. cat (3 of 3 votes)
The 3 nearest are 0.4 dog, 0.7 cat and 0.9 cat, so cat wins the vote 2 to 1.
Play AI & ML ▸