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

Update neighbors with latest changes to BallTree.

parent b4a6b576
Branches
Tags
No related merge requests found
...@@ -23,11 +23,10 @@ class NeighborsClassifier(BaseEstimator, ClassifierMixin): ...@@ -23,11 +23,10 @@ class NeighborsClassifier(BaseEstimator, ClassifierMixin):
window_size : int, optional window_size : int, optional
Window size passed to BallTree Window size passed to BallTree
algorithm : {'auto', 'ball_tree', 'brute', 'brute_inplace'}, optional algorithm : {'auto', 'ball_tree', 'brute'}, optional
Algorithm used to compute the nearest neighbors. 'ball_tree' Algorithm used to compute the nearest neighbors. 'ball_tree' will
will construct a BallTree, 'brute' and 'brute_inplace' will construct a BallTree while 'brute'will perform brute-force
perform brute-force search.'auto' will guess the most search. 'auto' will guess the most appropriate based on current dataset.
appropriate based on current dataset.
Examples Examples
-------- --------
...@@ -136,9 +135,6 @@ class NeighborsClassifier(BaseEstimator, ClassifierMixin): ...@@ -136,9 +135,6 @@ class NeighborsClassifier(BaseEstimator, ClassifierMixin):
self._set_params(**params) self._set_params(**params)
X = np.atleast_2d(X) X = np.atleast_2d(X)
if self.ball_tree is None: if self.ball_tree is None:
if self.algorithm == 'brute_inplace' and not return_distance:
return knn_brute(self._fit_X, X, self.n_neighbors)
else:
dist = euclidean_distances(X, self._fit_X, squared=True) dist = euclidean_distances(X, self._fit_X, squared=True)
# XXX: should be implemented with a partial sort # XXX: should be implemented with a partial sort
neigh_ind = dist.argsort(axis=1)[:, :self.n_neighbors] neigh_ind = dist.argsort(axis=1)[:, :self.n_neighbors]
...@@ -205,11 +201,11 @@ class NeighborsRegressor(NeighborsClassifier, RegressorMixin): ...@@ -205,11 +201,11 @@ class NeighborsRegressor(NeighborsClassifier, RegressorMixin):
mode : {'mean', 'barycenter'}, optional mode : {'mean', 'barycenter'}, optional
Weights to apply to labels. Weights to apply to labels.
algorithm : {'auto', 'ball_tree', 'brute', 'brute_inplace'}, optional algorithm : {'auto', 'ball_tree', 'brute'}, optional
Algorithm used to compute the nearest neighbors. 'ball_tree' Algorithm used to compute the nearest neighbors. 'ball_tree' will
will construct a BallTree, 'brute' and 'brute_inplace' will construct a BallTree, while 'brute' will perform brute-force
perform brute-force search.'auto' will guess the most search. 'auto' will guess the most appropriate based on current
appropriate based on current dataset. dataset.
Examples Examples
-------- --------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment