Question



Breaking a "tie" for K-nearest neighbors

How should we proceed when two points have the same euclidian distance but only one can be included?

For instance, if k = 5 and two points are tied for 5th nearest neighbor and also have different corresponding response variables.





Answers and follow-up questions





Answer or follow-up question 1

Dear student,

There are two approaches:
1. break the tie randomly
2. select all the neighbors that have a distance equal to the smallest k (5 in your case) distances

Option 2 would require more programming to handle the different number of neighbors.

While the first option might seem suboptimal, we'll learn in subsequent classes that randomness is often a good thing.

Michel Ballings



Sign in to be able to add an answer or mark this question as resolved.