Skip to content
Snippets Groups Projects
Commit b137987c authored by Fabian Pedregosa's avatar Fabian Pedregosa
Browse files

Fix doctest in neighbors module.

From: Fabian Pedregosa <fabian.pedregosa@inria.fr>

git-svn-id: https://scikit-learn.svn.sourceforge.net/svnroot/scikit-learn/trunk@578 22fbfee3-77ab-4535-9bad-27d1bd3bc7d8
parent 538bad1a
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ class Neighbors: ...@@ -31,7 +31,7 @@ class Neighbors:
>>> labels = [0,0,1,1] >>> labels = [0,0,1,1]
>>> neigh = Neighbors(k=3) >>> neigh = Neighbors(k=3)
>>> neigh.fit(samples, labels) #doctest: +ELLIPSIS >>> neigh.fit(samples, labels) #doctest: +ELLIPSIS
<scikits.learn.neighbors.neighbors.Neighbors instance at 0x...> <scikits.learn.neighbors.Neighbors instance at 0x...>
>>> print neigh.predict([[0,0,0]]) >>> print neigh.predict([[0,0,0]])
[0] [0]
""" """
...@@ -80,9 +80,9 @@ class Neighbors: ...@@ -80,9 +80,9 @@ class Neighbors:
>>> labels = [0, 0, 1] >>> labels = [0, 0, 1]
>>> neigh = Neighbors(k=1) >>> neigh = Neighbors(k=1)
>>> neigh.fit(samples, labels) #doctest: +ELLIPSIS >>> neigh.fit(samples, labels) #doctest: +ELLIPSIS
<scikits.learn.neighbors.neighbors.Neighbors instance at 0x...> <scikits.learn.neighbors.Neighbors instance at 0x...>
>>> print neigh.kneighbors([1., 1., 1.]) >>> print neigh.kneighbors([1., 1., 1.])
(0.5, 2) (array(0.5), array(2))
As you can see, it returns [0.5], and [2], which means that the As you can see, it returns [0.5], and [2], which means that the
element is at distance 0.5 and is the third element of samples element is at distance 0.5 and is the third element of samples
...@@ -120,7 +120,7 @@ class Neighbors: ...@@ -120,7 +120,7 @@ class Neighbors:
>>> labels = [0, 0, 1] >>> labels = [0, 0, 1]
>>> neigh = Neighbors(k=1) >>> neigh = Neighbors(k=1)
>>> neigh.fit(samples, labels) #doctest: +ELLIPSIS >>> neigh.fit(samples, labels) #doctest: +ELLIPSIS
<scikits.learn.neighbors.neighbors.Neighbors instance at 0x...> <scikits.learn.neighbors.Neighbors instance at 0x...>
>>> print neigh.predict([.2, .1, .2]) >>> print neigh.predict([.2, .1, .2])
0 0
>>> print neigh.predict([[0., -1., 0.], [3., 2., 0.]]) >>> print neigh.predict([[0., -1., 0.], [3., 2., 0.]])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment