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

Skip to content

MNT simple deprecations and removals for 0.21 #12238

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 12 commits into from
Oct 11, 2018
21 changes: 1 addition & 20 deletions doc/modules/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1512,23 +1512,4 @@ To be removed in 0.22
:template: deprecated_function.rst

covariance.graph_lasso
datasets.fetch_mldata


To be removed in 0.21
---------------------

.. autosummary::
:toctree: generated/
:template: deprecated_class.rst

linear_model.RandomizedLasso
linear_model.RandomizedLogisticRegression
neighbors.LSHForest

.. autosummary::
:toctree: generated/
:template: deprecated_function.rst

datasets.load_mlcomp
linear_model.lasso_stability_path
datasets.fetch_mldata
12 changes: 2 additions & 10 deletions sklearn/cluster/hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,8 @@ def ward_tree(X, connectivity=None, n_clusters=None, return_distance=False):


# single average and complete linkage
def linkage_tree(X, connectivity=None, n_components='deprecated',
n_clusters=None, linkage='complete', affinity="euclidean",
return_distance=False):
def linkage_tree(X, connectivity=None, n_clusters=None, linkage='complete',
affinity="euclidean", return_distance=False):
"""Linkage agglomerative clustering based on a Feature matrix.

The inertia matrix uses a Heapq-based representation.
Expand All @@ -362,9 +361,6 @@ def linkage_tree(X, connectivity=None, n_components='deprecated',
be symmetric and only the upper triangular half is used.
Default is None, i.e, the Ward algorithm is unstructured.

n_components : int (optional)
The number of connected components in the graph.

n_clusters : int (optional)
Stop early the construction of the tree at n_clusters. This is
useful to decrease computation time if the number of clusters is
Expand Down Expand Up @@ -420,10 +416,6 @@ def linkage_tree(X, connectivity=None, n_components='deprecated',
--------
ward_tree : hierarchical clustering with ward linkage
"""
if n_components != 'deprecated':
warnings.warn("n_components was deprecated in 0.19"
"will be removed in 0.21", DeprecationWarning)

X = np.asarray(X)
if X.ndim == 1:
X = np.reshape(X, (-1, 1))
Expand Down
15 changes: 0 additions & 15 deletions sklearn/cluster/tests/test_hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@
from sklearn.datasets import make_moons, make_circles


def test_deprecation_of_n_components_in_linkage_tree():
rng = np.random.RandomState(0)
X = rng.randn(50, 100)
# Test for warning of deprecation of n_components in linkage_tree
children, n_nodes, n_leaves, parent = assert_warns(DeprecationWarning,
linkage_tree,
X.T,
n_components=10)
children_t, n_nodes_t, n_leaves_t, parent_t = linkage_tree(X.T)
assert_array_equal(children, children_t)
assert_equal(n_nodes, n_nodes_t)
assert_equal(n_leaves, n_leaves_t)
assert_equal(parent, parent_t)


def test_linkage_misc():
# Misc tests on linkage
rng = np.random.RandomState(42)
Expand Down
6 changes: 0 additions & 6 deletions sklearn/covariance/graph_lasso_.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,6 @@ def __init__(self, alphas=4, n_refinements=4, cv='warn', tol=1e-4,
self.cv = cv
self.n_jobs = n_jobs

@property
@deprecated("Attribute grid_scores was deprecated in version 0.19 and "
"will be removed in 0.21. Use ``grid_scores_`` instead")
def grid_scores(self):
return self.grid_scores_

def fit(self, X, y=None):
"""Fits the GraphicalLasso covariance model to X.

Expand Down
25 changes: 0 additions & 25 deletions sklearn/covariance/tests/test_graph_lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from sklearn.utils.testing import assert_array_almost_equal
from sklearn.utils.testing import assert_array_less
from sklearn.utils.testing import assert_warns_message
from sklearn.utils.testing import ignore_warnings

from sklearn.covariance import (graph_lasso, GraphLasso, GraphLassoCV,
Expand All @@ -19,8 +18,6 @@
from sklearn.utils import check_random_state
from sklearn import datasets

from numpy.testing import assert_equal


@ignore_warnings(category=DeprecationWarning)
def test_graph_lasso(random_state=0):
Expand Down Expand Up @@ -141,25 +138,3 @@ def test_graph_lasso_cv(random_state=1):

# Smoke test with specified alphas
GraphLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1).fit(X)


@ignore_warnings(category=DeprecationWarning)
@pytest.mark.filterwarnings('ignore: You should specify a value') # 0.22
def test_deprecated_grid_scores(random_state=1):
dim = 5
n_samples = 6
random_state = check_random_state(random_state)
prec = make_sparse_spd_matrix(dim, alpha=.96,
random_state=random_state)
cov = linalg.inv(prec)
X = random_state.multivariate_normal(np.zeros(dim), cov, size=n_samples)
graph_lasso = GraphLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1)
graph_lasso.fit(X)

depr_message = ("Attribute grid_scores was deprecated in version "
"0.19 and will be removed in 0.21. Use "
"``grid_scores_`` instead")

assert_warns_message(DeprecationWarning, depr_message,
lambda: graph_lasso.grid_scores)
assert_equal(graph_lasso.grid_scores, graph_lasso.grid_scores_)
26 changes: 0 additions & 26 deletions sklearn/covariance/tests/test_graphical_lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@

from sklearn.utils.testing import assert_array_almost_equal
from sklearn.utils.testing import assert_array_less
from sklearn.utils.testing import assert_warns_message

from sklearn.covariance import (graphical_lasso, GraphicalLasso,
GraphicalLassoCV, empirical_covariance)
from sklearn.datasets.samples_generator import make_sparse_spd_matrix
from sklearn.externals.six.moves import StringIO
from sklearn.utils import check_random_state
from sklearn import datasets
from sklearn.utils.fixes import PY3_OR_LATER

from numpy.testing import assert_equal


def test_graphical_lasso(random_state=0):
Expand Down Expand Up @@ -137,25 +133,3 @@ def test_graphical_lasso_cv(random_state=1):

# Smoke test with specified alphas
GraphicalLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1).fit(X)


@pytest.mark.filterwarnings('ignore: You should specify a value') # 0.22
@pytest.mark.skipif(not PY3_OR_LATER,
reason='On Python 2 DeprecationWarning is not issued for some unkown reason.')
def test_deprecated_grid_scores(random_state=1):
dim = 5
n_samples = 6
random_state = check_random_state(random_state)
prec = make_sparse_spd_matrix(dim, alpha=.96,
random_state=random_state)
cov = linalg.inv(prec)
X = random_state.multivariate_normal(np.zeros(dim), cov, size=n_samples)
graphical_lasso = GraphicalLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1)
graphical_lasso.fit(X)

depr_message = ("Attribute grid_scores was deprecated in version "
"0.19 and will be removed in 0.21. Use "
"``grid_scores_`` instead")

with pytest.warns(DeprecationWarning, match=depr_message):
assert_equal(graphical_lasso.grid_scores, graphical_lasso.grid_scores_)
2 changes: 0 additions & 2 deletions sklearn/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from .base import clear_data_home
from .covtype import fetch_covtype
from .kddcup99 import fetch_kddcup99
from .mlcomp import load_mlcomp
from .lfw import fetch_lfw_pairs
from .lfw import fetch_lfw_people
from .twenty_newsgroups import fetch_20newsgroups
Expand Down Expand Up @@ -75,7 +74,6 @@
'load_iris',
'load_breast_cancer',
'load_linnerud',
'load_mlcomp',
'load_sample_image',
'load_sample_images',
'load_svmlight_file',
Expand Down
114 changes: 0 additions & 114 deletions sklearn/datasets/mlcomp.py

This file was deleted.

12 changes: 2 additions & 10 deletions sklearn/decomposition/fastica_.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from ..exceptions import ConvergenceWarning
from ..externals import six
from ..externals.six import moves
from ..externals.six import string_types
from ..utils import check_array, as_float_array, check_random_state
from ..utils.validation import check_is_fitted
from ..utils.validation import FLOAT_DTYPES
Expand Down Expand Up @@ -553,29 +552,22 @@ def fit(self, X, y=None):
self._fit(X, compute_sources=False)
return self

def transform(self, X, y='deprecated', copy=True):
def transform(self, X, copy=True):
"""Recover the sources from X (apply the unmixing matrix).

Parameters
----------
X : array-like, shape (n_samples, n_features)
Data to transform, where n_samples is the number of samples
and n_features is the number of features.
y : (ignored)
.. deprecated:: 0.19
This parameter will be removed in 0.21.

copy : bool (optional)
If False, data passed to fit are overwritten. Defaults to True.

Returns
-------
X_new : array-like, shape (n_samples, n_components)
"""
if not isinstance(y, string_types) or y != 'deprecated':
warnings.warn("The parameter y on transform() is "
"deprecated since 0.19 and will be removed in 0.21",
DeprecationWarning)

check_is_fitted(self, 'mixing_')

X = check_array(X, copy=copy, dtype=FLOAT_DTYPES)
Expand Down
Loading