I've also made an egg for OS X that statically links the ANN library. You should be able to install via (one line):
easy_install -f http://rieke-server.physiol.washington.edu/~barry/python scigpl.ann
Of course, you can still get it via the scikits SVN.
Here's how the new API looks:
>>> import scigpl.ann as ann
>>> import numpy as np
>>> k=ann.kdtree(np.array([[0.,0],[1,0],[1.5,2]]))
>>> k.knn([0,.2],1)
(array([[0]]), array([[ 0.04]]))
>>> k.knn([0,.2],2)
(array([[0, 1]]), array([[ 0.04, 1.04]]))
>>> k.knn([[0,.2],[.1,2],[3,1],[0,0]],2)
(array([[0, 1],
[2, 0],
[2, 1],
[1, 2]]), array([[ 0.04, 1.04],
[ 1.96, 4.01],
[ 3.25, 5. ],
[ 1. , 6.25]]))
>>> k.knn([[0,.2],[.1,2],[3,1],[0,0]],3)
(array([[ 0, 1, 2],
[ 2, 0, 1],
[ 2, 1, 0],
[ 1, 2, -1]]), array([[ 4.00000000e-002, 1.04000000e+000, 5.49000000e+000],
[ 1.96000000e+000, 4.01000000e+000, 4.81000000e+000],
[ 3.25000000e+000, 5.00000000e+000, 1.00000000e+001],
[ 1.00000000e+000, 6.25000000e+000, 1.79769313e+308]]))
No comments:
Post a Comment