8000 simple deprecations and removals · scikit-learn/scikit-learn@c56c2af · GitHub
[go: up one dir, main page]

Skip to content

Commit c56c2af

Browse files
committed
simple deprecations and removals
1 parent 94c70ff commit c56c2af

37 files changed

+43
-2726
lines changed

doc/modules/classes.rst

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
15121512
:template: deprecated_function.rst
15131513

15141514
covariance.graph_lasso
1515-
datasets.fetch_mldata
1516-
1517-
1518-
To be removed in 0.21
1519-
---------------------
1520-
1521-
.. autosummary::
1522-
:toctree: generated/
1523-
:template: deprecated_class.rst
1524-
1525-
linear_model.RandomizedLasso
1526-
linear_model.RandomizedLogisticRegression
1527-
neighbors.LSHForest
1528-
1529-
.. autosummary::
1530-
:toctree: generated/
1531-
:template: deprecated_function.rst
1532-
1533-
datasets.load_mlcomp
1534-
linear_model.lasso_stability_path
1515+
datasets.fetch_mldata

sklearn/cluster/hierarchical.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,8 @@ def ward_tree(X, connectivity=None, n_clusters=None, return_distance=False):
339339

340340

341341
# single average and complete linkage
342-
def linkage_tree(X, connectivity=None, n_components='deprecated',
343-
n_clusters=None, linkage='complete', affinity="euclidean",
344-
return_distance=False):
342+
def linkage_tree(X, connectivity=None, n_clusters=None, linkage='complete',
343+
affinity="euclidean", return_distance=False):
345344
"""Linkage agglomerative clustering based on a Feature matrix.
346345
347346
The inertia matrix uses a Heapq-based representation.
@@ -362,9 +361,6 @@ def linkage_tree(X, connectivity=None, n_components='deprecated',
362361
be symmetric and only the upper triangular half is used.
363362
Default is None, i.e, the Ward algorithm is unstructured.
364363
365-
n_components : int (optional)
366-
The number of connected components in the graph.
367-
368364
n_clusters : int (optional)
369365
Stop early the construction of the tree at n_clusters. This is
370366
useful to decrease computation time if the number of clusters is
@@ -420,10 +416,6 @@ def linkage_tree(X, connectivity=None, n_components='deprecated',
420416
--------
421417
ward_tree : hierarchical clustering with ward linkage
422418
"""
423-
if n_components != 'deprecated':
424-
warnings.warn("n_components was deprecated in 0.19"
425-
"will be removed in 0.21", DeprecationWarning)
426-
427419
X = np.asarray(X)
428420
if X.ndim == 1:
429421
X = np.reshape(X, (-1, 1))

sklearn/covariance/graph_lasso_.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,6 @@ def __init__(self, alphas=4, n_refinements=4, cv='warn', tol=1e-4,
584584
self.cv = cv
585585
self.n_jobs = n_jobs
586586

587-
@property
588-
@deprecated("Attribute grid_scores was deprecated in version 0.19 and "
589-
"will be removed in 0.21. Use ``grid_scores_`` instead")
590-
def grid_scores(self):
591-
return self.grid_scores_
592-
593587
def fit(self, X, y=None):
594588
"""Fits the GraphicalLasso covariance model to X.
595589

sklearn/covariance/tests/test_graph_lasso.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,26 +140,4 @@ def test_graph_lasso_cv(random_state=1):
140140
sys.stdout = orig_stdout
141141

142142
# Smoke test with specified alphas
143-
GraphLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1).fit(X)
144-
145-
146-
@ignore_warnings(category=DeprecationWarning)
147-
@pytest.mark.filterwarnings('ignore: You should specify a value') # 0.22
148-
def test_deprecated_grid_scores(random_state=1):
149-
dim = 5
150-
n_samples = 6
151-
random_state = check_random_state(random_state)
152-
prec = make_sparse_spd_matrix(dim, alpha=.96,
153-
random_state=random_state)
154-
cov = linalg.inv(prec)
155-
X = random_state.multivariate_normal(np.zeros(dim), cov, size=n_samples)
156-
graph_lasso = GraphLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1)
157-
graph_lasso.fit(X)
158-
159-
depr_message = ("Attribute grid_scores was deprecated in version "
160-
"0.19 and will be removed in 0.21. Use "
161-
"``grid_scores_`` instead")
162-
163-
assert_warns_message(DeprecationWarning, depr_message,
164-
lambda: graph_lasso.grid_scores)
165-
assert_equal(graph_lasso.grid_scores, graph_lasso.grid_scores_)
143+
GraphLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1).fit(X)

sklearn/covariance/tests/test_graphical_lasso.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -136,26 +136,4 @@ def test_graphical_lasso_cv(random_state=1):
136136
sys.stdout = orig_stdout
137137

138138
# Smoke test with specified alphas
139-
GraphicalLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1).fit(X)
140-
141-
142-
@pytest.mark.filterwarnings('ignore: You should specify a value') # 0.22
143-
@pytest.mark.skipif(not PY3_OR_LATER,
144-
reason='On Python 2 DeprecationWarning is not issued for some unkown reason.')
145-
def test_deprecated_grid_scores(random_state=1):
146-
dim = 5
147-
n_samples = 6
148-
random_state = check_random_state(random_state)
149-
prec = make_sparse_spd_matrix(dim, alpha=.96,
150-
random_state=random_state)
151-
cov = linalg.inv(prec)
152-
X = random_state.multivariate_normal(np.zeros(dim), cov, size=n_samples)
153-
graphical_lasso = GraphicalLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1)
154-
graphical_lasso.fit(X)
155-
156-
depr_message = ("Attribute grid_scores was deprecated in version "
157-
"0.19 and will be removed in 0.21. Use "
158-
"``grid_scores_`` instead")
159-
160-
with pytest.warns(DeprecationWarning, match=depr_message):
161-
assert_equal(graphical_lasso.grid_scores, graphical_lasso.grid_scores_)
139+
GraphicalLassoCV(alphas=[0.8, 0.5], tol=1e-1, n_jobs=1).fit(X)

sklearn/datasets/mlcomp.py

Lines changed: 0 additions & 114 deletions
This file was deleted.

sklearn/decomposition/fastica_.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,29 +553,22 @@ def fit(self, X, y=None):
553553
self._fit(X, compute_sources=False)
554554
return self
555555

556-
def transform(self, X, y='deprecated', copy=True):
556+
def transform(self, X, copy=True):
557557
"""Recover the sources from X (apply the unmixing matrix).
558558
559559
Parameters
560560
----------
561561
X : array-like, shape (n_samples, n_features)
562562
Data to transform, where n_samples is the number of samples
563563
and n_features is the number of features.
564-
y : (ignored)
565-
.. deprecated:: 0.19
566-
This parameter will be removed in 0.21.
564+
567565
copy : bool (optional)
568566
If False, data passed to fit are overwritten. Defaults to True.
569567
570568
Returns
571569
-------
572570
X_new : array-like, shape (n_samples, n_components)
573571
"""
574-
if not isinstance(y, string_types) or y != 'deprecated':
575-
warnings.warn("The parameter y on transform() is "
576-
"deprecated since 0.19 and will be removed in 0.21",
577-
DeprecationWarning)
578-
579572
check_is_fitted(self, 'mixing_')
580573

581574
X = check_array(X, copy=copy, dtype=FLOAT_DTYPES)

sklearn/decomposition/online_lda.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,6 @@ class LatentDirichletAllocation(BaseEstimator, TransformerMixin):
230230
If None, the random number generator is the RandomState instance used
231231
by `np.random`.
232232
233-
n_topics : int, optional (default=None)
234-
This parameter has been renamed to n_components and will
235-
be removed in version 0.21.
236-
.. deprecated:: 0.19
237-
238233
Attributes
239234
----------
240235
components_ : array, [n_components, n_features]
@@ -286,7 +281,7 @@ def __init__(self, n_components=10, doc_topic_prior=None,
286281
learning_decay=.7, learning_offset=10., max_iter=10,
287282
batch_size=128, evaluate_every=-1, total_samples=1e6,
288283
perp_tol=1e-1, mean_change_tol=1e-3, max_doc_update_iter=100,
289-
n_jobs=None, verbose=0, random_state=None, n_topics=None):
284+
n_jobs=None, verbose=0, random_state=None):
290285
self.n_components = n_components
291286
self.doc_topic_prior = doc_topic_prior
292287
self.topic_word_prior = topic_word_prior
@@ -303,21 +298,12 @@ def __init__(self, n_components=10, doc_topic_prior=None,
303298
self.n_jobs = n_jobs
304299
self.verbose = verbose
305300
self.random_state = random_state
306-
self.n_topics = n_topics
307301

308302
def _check_params(self):
309303
"""Check model parameters."""
310-
if self.n_topics is not None:
311-
self._n_components = self.n_topics
312-
warnings.warn("n_topics has been renamed to n_components in "
313-
"version 0.19 and will be removed in 0.21",
314-
DeprecationWarning)
315-
else:
316-
self._n_components = self.n_components
317-
318-
if self._n_components <= 0:
304+
if self.n_components <= 0:
319305
raise ValueError("Invalid 'n_components' parameter: %r"
320-
% self._n_components)
306+
% self.n_components)
321307

322308
if self.total_samples <= 0:
323309
raise ValueError("Invalid 'total_samples' parameter: %r"
@@ -339,20 +325,20 @@ def _init_latent_vars(self, n_features):
339325
self.n_iter_ = 0
340326

341327
if self.doc_topic_prior is None:
342-
self.doc_topic_prior_ = 1. / self._n_components
328+
self.doc_topic_prior_ = 1. / self.n_components
343329
else:
344330
self.doc_topic_prior_ = self.doc_topic_prior
345331

346332
if self.topic_word_prior is None:
347-
self.topic_word_prior_ = 1. / self._n_components
333+
self.topic_word_prior_ = 1. / self.n_components
348334
else:
349335
self.topic_word_prior_ = self.topic_word_prior
350336

351337
init_gamma = 100.
352338
init_var = 1. / init_gamma
353339
# In the literature, this is called `lambda`
354340
self.components_ = self.random_state_.gamma(
355-
init_gamma, init_var, (self._n_components, n_features))
341+
init_gamma, init_var, (self.n_components, n_features))
356342

357343
# In the literature, this is `exp(E[log(beta)])`
358344
self.exp_dirichlet_component_ = np.exp(
@@ -711,7 +697,7 @@ def _loglikelihood(prior, distr, dirichlet_distr, size):
711697

712698
# compute E[log p(theta | alpha) - log q(theta | gamma)]
713699
score += _loglikelihood(doc_topic_prior, doc_topic_distr,
714-
dirichlet_doc_topic, self._n_components)
700+
dirichlet_doc_topic, self.n_components)
715701

716702
# Compensate for the subsampling of the population of documents
717703
if sub_sampling:
@@ -781,7 +767,7 @@ def _perplexity_precomp_distr(self, X, doc_topic_distr=None,
781767
raise ValueError("Number of samples in X and doc_topic_distr"
782768
" do not match.")
783769

784-
if n_components != self._n_components:
770+
if n_components != self.n_components:
785771
raise ValueError("Number of topics does not match.")
786772

787773
current_samples = X.shape[0]
@@ -795,7 +781,7 @@ def _perplexity_precomp_distr(self, X, doc_topic_distr=None,
795781

796782
return np.exp(-1.0 * perword_bound)
797783

798-
def perplexity(self, X, doc_topic_distr='deprecated', sub_sampling=False):
784+
def perplexity(self, X, sub_sampling=False):
799785
"""Calculate approximate perplexity for data X.
800786
801787
Perplexity is defined as exp(-1. * log-likelihood per word)
@@ -823,10 +809,4 @@ def perplexity(self, X, doc_topic_distr='deprecated', sub_sampling=False):
823809
score : float
824810
Perplexity score.
825811
"""
826-
if doc_topic_distr != 'deprecated':
827-
warnings.warn("Argument 'doc_topic_distr' is deprecated and is "
828-
"being ignored as of 0.19. Support for this "
829-
"argument will be removed in 0.21.",
830-
DeprecationWarning)
831-
832812
return self._perplexity_precomp_distr(X, sub_sampling=sub_sampling)

0 commit comments

Comments
 (0)
0