saisrivatsan / aima-python

Automatically exported from code.google.com/p/aima-python
0 stars 0 forks source link

bug in NearestNeighborLearner class in learning.py #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
"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

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r71.

Original comment by wit...@gmail.com on 15 Sep 2011 at 2:41