Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scikit-learn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ian Johnson
scikit-learn
Commits
856e9a1d
Commit
856e9a1d
authored
14 years ago
by
Fabian Pedregosa
Browse files
Options
Downloads
Patches
Plain Diff
Update neighbors with latest changes to BallTree.
parent
b4a6b576
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scikits/learn/neighbors.py
+12
-16
12 additions, 16 deletions
scikits/learn/neighbors.py
with
12 additions
and
16 deletions
scikits/learn/neighbors.py
+
12
−
16
View file @
856e9a1d
...
@@ -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
--------
--------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment