K nearest neighbors model doesn't randomize the dataset row order - why?

Hi all,

In this screen, the k nearest neighbors model doesn’t randomize the dataset rows before sorting them.

But in the previous mission, we set a random seed and then randomize the dataset rows.

Why the discrepancy?

Hey, Martin.

Nice catch! It ends up not really mattering because the sorting algorithm will randomize the results for each tie in the distance column. (It doesn’t randomize on purpose, it’s just that the way the algorithm works deals with ties randomly).

It’s good practice to randomize it anyway as these things tend to depend on the implementation of the algorithm.