@@ -22,8 +22,8 @@ class NeighborsClassifier(BaseEstimator, ClassifierMixin):
22
22
window_size : int, optional
23
23
Window size passed to BallTree
24
24
25
- strategy : {'auto', 'ball_tree', 'brute', 'brute_inplace'}, optional
26
- Strategy used to compute the nearest neighbors. 'ball_tree'
25
+ algorithm : {'auto', 'ball_tree', 'brute', 'brute_inplace'}, optional
26
+ Algorithm used to compute the nearest neighbors. 'ball_tree'
27
27
will construct a BallTree, 'brute' and 'brute_inplace' will
28
28
perform brute-force search.'auto' will guess the most
29
29
appropriate based on current dataset.
@@ -35,7 +35,7 @@ class NeighborsClassifier(BaseEstimator, ClassifierMixin):
35
35
>>> from scikits.learn.neighbors import NeighborsClassifier
36
36
>>> neigh = NeighborsClassifier(n_neighbors=1)
37
37
>>> neigh.fit(samples, labels)
38
- NeighborsClassifier(n_neighbors=1, window_size=1, strategy ='auto')
38
+ NeighborsClassifier(n_neighbors=1, window_size=1, algorithm ='auto')
39
39
>>> print neigh.predict([[0,0,0]])
40
40
[1]
41
41
@@ -48,10 +48,10 @@ class NeighborsClassifier(BaseEstimator, ClassifierMixin):
48
48
http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm
49
49
"""
50
50
51
- def __init__ (self , n_neighbors = 5 , strategy = 'auto' , window_size = 1 ):
51
+ def __init__ (self , n_neighbors = 5 , algorithm = 'auto' , window_size = 1 ):
52
52
self .n_neighbors = n_neighbors
53
53
self .window_size = window_size
54
- self .strategy = strategy
54
+ self .algorithm = algorithm
55
55
56
56
57
57
def fit (self , X , Y , ** params ):
@@ -73,8 +73,8 @@ def fit(self, X, Y, **params):
73
73
self ._y = np .asanyarray (Y )
74
74
self ._set_params (** params )
75
75
76
- if self .strategy == 'ball_tree' or \
77
- (self .strategy == 'auto' and X .shape [1 ] < 20 ):
76
+ if self .algorithm == 'ball_tree' or \
77
+ (self .algorithm == 'auto' and X .shape [1 ] < 20 ):
78
78
self .ball_tree = BallTree (X , self .window_size )
79
79
else :
80
80
self .ball_tree = None
@@ -119,7 +119,7 @@ class from an array representing our data set and ask who's
119
119
>>> from scikits.learn.neighbors import NeighborsClassifier
120
120
>>> neigh = NeighborsClassifier(n_neighbors=1)
121
121
>>> neigh.fit(samples, labels)
122
- NeighborsClassifier(n_neighbors=1, window_size=1, strategy ='auto')
122
+ NeighborsClassifier(n_neighbors=1, window_size=1, algorithm ='auto')
123
123
>>> print neigh.kneighbors([1., 1., 1.])
124
124
(array([ 0.5]), array([2]))
125
125
@@ -160,7 +160,7 @@ def predict(self, X, **params):
160
160
161
161
# .. get neighbors ..
162
162
if self .ball_tree is None :
163
- if self .strategy == 'brute_inplace' :
163
+ if self .algorithm == 'brute_inplace' :
164
164
neigh_ind = knn_brute (self ._fit_X , X , self .n_neighbors )
165
165
else :
166
166
from .metrics import euclidean_distances
@@ -203,8 +203,8 @@ class NeighborsRegressor(NeighborsClassifier, RegressorMixin):
203
203
mode : {'mean', 'barycenter'}, optional
204
204
Weights to apply to labels.
205
205
206
- strategy : {'auto', 'ball_tree', 'brute', 'brute_inplace'}, optional
207
- Strategy used to compute the nearest neighbors. 'ball_tree'
206
+ algorithm : {'auto', 'ball_tree', 'brute', 'brute_inplace'}, optional
207
+ Algorithm used to compute the nearest neighbors. 'ball_tree'
208
208
will construct a BallTree, 'brute' and 'brute_inplace' will
209
209
perform brute-force search.'auto' will guess the most
210
210
appropriate based on current dataset.
@@ -216,7 +216,8 @@ class NeighborsRegressor(NeighborsClassifier, RegressorMixin):
216
216
>>> from scikits.learn.neighbors import NeighborsRegressor
217
217
>>> neigh = NeighborsRegressor(n_neighbors=2)
218
218
>>> neigh.fit(X, y)
219
- NeighborsRegressor(n_neighbors=2, window_size=1, mode='mean', strategy='auto')
219
+ NeighborsRegressor(n_neighbors=2, window_size=1, mode='mean',
220
+ algorithm='auto')
220
221
>>> print neigh.predict([[1.5]])
221
222
[ 0.5]
222
223
@@ -226,12 +227,12 @@ class NeighborsRegressor(NeighborsClassifier, RegressorMixin):
226
227
"""
227
228
228
229
229
- def __init__ (self , n_neighbors = 5 , mode = 'mean' , strategy = 'auto' ,
230
+ def __init__ (self , n_neighbors = 5 , mode = 'mean' , algorithm = 'auto' ,
230
231
window_size = 1 ):
231
232
self .n_neighbors = n_neighbors
232
233
self .window_size = window_size
233
234
self .mode = mode
234
- self .strategy = strategy
235
+ self .algorithm = algorithm
235
236
236
237
237
238
def predict (self , X , ** params ):
@@ -256,7 +257,7 @@ def predict(self, X, **params):
256
257
257
258
# .. get neighbors ..
258
259
if self .ball_tree is None :
259
- if self .strategy == 'brute_inplace' :
260
+ if self .algorithm == 'brute_inplace' :
260
261
neigh_ind = knn_brute (self ._fit_X , X , self .n_neighbors )
261
262
else :
262
263
from .metrics .pairwise import euclidean_distances
0 commit comments