Skip to content

Commit 329aa4e

Browse files
jaquesgrobleramueller
authored andcommitted
deprecation warnings, indent fix
1 parent 82bcda2 commit 329aa4e

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

doc/modules/neighbors.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ of each option, see `Nearest Neighbor Algorithms`_.
5454
.. warning::
5555

5656
Regarding the Nearest Neighbors algorithms, if it is found that two
57-
neighbors, neighbor `k+1` and `k`, have identical distances but
58-
but different labels, the results will depend on the odering of the
59-
training data.
57+
neighbors, neighbor `k+1` and `k`, have identical distances but
58+
but different labels, the results will depend on the odering of the
59+
training data.
6060

6161
.. _classification:
6262

sklearn/neighbors/classification.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#
88
# License: BSD, (C) INRIA, University of Amsterdam
99

10+
import warnings
11+
1012
import numpy as np
1113
from scipy import stats
1214
from ..utils.extmath import weighted_mode
@@ -103,7 +105,13 @@ class KNeighborsClassifier(NeighborsBase, KNeighborsMixin,
103105

104106
def __init__(self, n_neighbors=5,
105107
weights='uniform',
106-
algorithm='auto', leaf_size=30, p=2):
108+
algorithm='auto', leaf_size=30, p=2, **kwargs):
109+
if kwargs:
110+
if 'warn_on_equidistant' in kwargs:
111+
warnings.warn("The warn_on_equidistant parameter is "
112+
"deprecated and will be removed in the future.",
113+
DeprecationWarning,
114+
stacklevel=2)
107115
self._init_params(n_neighbors=n_neighbors,
108116
algorithm=algorithm,
109117
leaf_size=leaf_size, p=p)

sklearn/neighbors/regression.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#
88
# License: BSD, (C) INRIA, University of Amsterdam
99

10+
import warnings
11+
1012
import numpy as np
1113

1214
from .base import \
@@ -102,7 +104,13 @@ class KNeighborsRegressor(NeighborsBase, KNeighborsMixin,
102104
"""
103105

104106
def __init__(self, n_neighbors=5, weights='uniform',
105-
algorithm='auto', leaf_size=30, p=2):
107+
algorithm='auto', leaf_size=30, p=2, **kwargs):
108+
if kwargs:
109+
if 'warn_on_equidistant' in kwargs:
110+
warnings.warn("The warn_on_equidistant parameter is "
111+
"deprecated and will be removed in the future",
112+
DeprecationWarning,
113+
stacklevel=2)
106114
self._init_params(n_neighbors=n_neighbors,
107115
algorithm=algorithm,
108116
leaf_size=leaf_size, p=p)

0 commit comments

Comments
 (0)