Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG] MNT Removed deprecated attributes and parameters #15803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions sklearn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,34 +406,17 @@ def score(self, X, y, sample_weight=None):

Notes
-----
The R2 score used when calling ``score`` on a regressor will use
The R2 score used when calling ``score`` on a regressor uses
``multioutput='uniform_average'`` from version 0.23 to keep consistent
with :func:`~sklearn.metrics.r2_score`. This will influence the
``score`` method of all the multioutput regressors (except for
:class:`~sklearn.multioutput.MultiOutputRegressor`). To specify the
default value manually and avoid the warning, please either call
:func:`~sklearn.metrics.r2_score` directly or make a custom scorer with
:func:`~sklearn.metrics.make_scorer` (the built-in scorer ``'r2'`` uses
``multioutput='uniform_average'``).
with default value of :func:`~sklearn.metrics.r2_score`.
This influences the ``score`` method of all the multioutput
regressors (except for
:class:`~sklearn.multioutput.MultiOutputRegressor`).
"""

from .metrics import r2_score
from .metrics._regression import _check_reg_targets
y_pred = self.predict(X)
# XXX: Remove the check in 0.23
y_type, _, _, _ = _check_reg_targets(y, y_pred, None)
if y_type == 'continuous-multioutput':
warnings.warn("The default value of multioutput (not exposed in "
"score method) will change from 'variance_weighted' "
"to 'uniform_average' in 0.23 to keep consistent "
"with 'metrics.r2_score'. To specify the default "
"value manually and avoid the warning, please "
"either call 'metrics.r2_score' directly or make a "
"custom scorer with 'metrics.make_scorer' (the "
"built-in scorer 'r2' uses "
"multioutput='uniform_average').", FutureWarning)
return r2_score(y, y_pred, sample_weight=sample_weight,
multioutput='variance_weighted')
return r2_score(y, y_pred, sample_weight=sample_weight)


class ClusterMixin:
Expand Down
7 changes: 0 additions & 7 deletions sklearn/cluster/_hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,6 @@ def __init__(self, n_clusters=2, affinity="euclidean",
self.linkage = linkage
self.affinity = affinity

@deprecated("The ``n_components_`` attribute was deprecated "
"in favor of ``n_connected_components_`` in 0.21 "
"and will be removed in 0.23.")
@property
def n_components_(self):
return self.n_connected_components_

def fit(self, X, y=None):
"""Fit the hierarchical clustering from features, or distance matrix.

Expand Down
14 changes: 0 additions & 14 deletions sklearn/cluster/tests/test_hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,17 +750,3 @@ def test_dist_threshold_invalid_parameters():
AgglomerativeClustering(n_clusters=None,
distance_threshold=1,
compute_full_tree=False).fit(X)


def test_n_components_deprecation():
# Test that a Deprecation warning is thrown when n_components_
# attribute is accessed

X = np.array([[1, 2], [1, 4], [1, 0], [4, 2]])
agc = AgglomerativeClustering().fit(X)

match = ("``n_components_`` attribute was deprecated "
"in favor of ``n_connected_components_``")
with pytest.warns(FutureWarning, match=match):
n = agc.n_components_
assert n == agc.n_connected_components_
1 change: 0 additions & 1 deletion sklearn/cross_decomposition/tests/test_pls.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ def test_pls_errors():
clf.fit, X, Y)


@pytest.mark.filterwarnings('ignore: The default value of multioutput') # 0.23
def test_pls_scaling():
# sanity check for scale=True
n_samples = 1000
Expand Down
6 changes: 0 additions & 6 deletions sklearn/decomposition/tests/test_kernel_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ def test_kernel_pca_invalid_kernel():
kpca.fit(X_fit)


# 0.23. warning about tol not having its correct default value.
@pytest.mark.filterwarnings('ignore:max_iter and tol parameters have been')
def test_gridsearch_pipeline():
# Test if we can do a grid-search to find parameters to separate
# circles with a perceptron model.
Expand All @@ -231,8 +229,6 @@ def test_gridsearch_pipeline():
assert grid_search.best_score_ == 1


# 0.23. warning about tol not having its correct default value.
@pytest.mark.filterwarnings('ignore:max_iter and tol parameters have been')
def test_gridsearch_pipeline_precomputed():
# Test if we can do a grid-search to find parameters to separate
# circles with a perceptron model using a precomputed kernel.
Expand All @@ -248,8 +244,6 @@ def test_gridsearch_pipeline_precomputed():
assert grid_search.best_score_ == 1


# 0.23. warning about tol not having its correct default value.
@pytest.mark.filterwarnings('ignore:max_iter and tol parameters have been')
def test_nested_circles():
# Test the linear separability of the first 2D KPCA transform
X, y = make_circles(n_samples=400, factor=.3, noise=.05,
Expand Down
Loading