[Biopython-dev] Problem with Bio.kNN module

kunal ghosh kunal.t2 at gmail.com
Thu Dec 30 08:03:40 UTC 2010


Hi all,

I wanted to use the kNN module provided by BioPython for my calculations.
So i tested the module with a simple data set which does something similar
that i wanted to do.
Here is what i did ,

I fed in 4 points
>>> xs = [[0,0],[10,0],[10,10],[0,10]]
all belonging to separate classes.
>>> ys = [0,1,2,3]
>>> k=4
>>> model = kNN.train(xs,ys,k)
>>> x1 = [11,10]
>>> kNN.classify(model, x1)
0

here lies the problem , the point x1 is closest to [10,10] so the
classification result should
be 2 .

So i went ahead and changed the kNN module to rectify this .
I have tested it with the sample data in the documentation as well and it
seems that it gives the right result.

Is this a bug in the kNN module or am i missing something ?
the diff is attached .

There are inline comments explaining why i have d

-- 
regards
-------
Kunal Ghosh
Dept of Computer Sc. & Engineering.
Sir MVIT
Bangalore,India

permalink: member.acm.org/~kunal.t2 <http://member.acm.org/%7Ekunal.t2>
Blog:kunalghosh.wordpress.com
Website:www.kunalghosh.net46.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kNN.diff
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/biopython-dev/attachments/20101230/d8221b22/attachment-0002.bin>


More information about the Biopython-dev mailing list