"best" is described as a sorted list of (distance, example) pairs.
Yet when looping over "examples" and filling this list, we simply append
while the count is less than "k", which violates the sorting condition. We
only start sorting once the list is full and the new example has a distance
less than the top of the list.
As an example, take k=5, and imagine a dataset where the first four
instances are the furthest from the example we want to predict. Then
imagine that the fifth example happens to be the closest. Then when we
evaluate the rest of the examples, none will be added to the list "best"
since the condition on line 225 is never met.
Original issue reported on code.google.com by amroamro...@gmail.com on 13 Dec 2009 at 2:04
Original issue reported on code.google.com by
amroamro...@gmail.com
on 13 Dec 2009 at 2:04