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)
- cat (2 of 3 votes)
- dog (nearest point)
- dog (2 of 3 votes)
- 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 ▸