Skip to content

Commit 6e50c8f

Browse files
waterponeyraghavrv
authored andcommitted
[MRG+2] DOC framework for keeping API refs for deprecated classes/funcs (scikit-learn#7725)
* DOC framework for keeping API refs for deprecated classes/funcs * DOC tagging deprecated for 0.20 * suggestion for LDA/QDA deprecation * simplify deprecation message for GaussianProcess * simplify deprecation messages * fixup avoid import QuadraticDiscriminantAnalysis in qda.QDA (and similar for LDA). * fixup test alias lda.LDA is instance of LinearDiscriminantAnalysis
1 parent 4ae1013 commit 6e50c8f

File tree

19 files changed

+336
-17
lines changed

19 files changed

+336
-17
lines changed

doc/modules/classes.rst

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ Splitter Functions
186186
:template: function.rst
187187

188188
model_selection.train_test_split
189+
model_selection.check_cv
189190

190191
Hyper-parameter optimizers
191192
--------------------------
@@ -201,6 +202,13 @@ Hyper-parameter optimizers
201202
model_selection.ParameterGrid
202203
model_selection.ParameterSampler
203204

205+
206+
.. autosummary::
207+
:toctree: generated/
208+
:template: function.rst
209+
210+
model_selection.fit_grid_point
211+
204212
Model validation
205213
----------------
206214

@@ -315,7 +323,6 @@ Samples generator
315323
decomposition.PCA
316324
decomposition.IncrementalPCA
317325
decomposition.ProjectedGradientNMF
318-
decomposition.RandomizedPCA
319326
decomposition.KernelPCA
320327
decomposition.FactorAnalysis
321328
decomposition.FastICA
@@ -560,7 +567,6 @@ From text
560567

561568
gaussian_process.GaussianProcessRegressor
562569
gaussian_process.GaussianProcessClassifier
563-
gaussian_process.GaussianProcess
564570

565571
Kernels:
566572

@@ -1349,3 +1355,67 @@ Low-level methods
13491355
utils.estimator_checks.check_estimator
13501356
utils.resample
13511357
utils.shuffle
1358+
1359+
1360+
Recently deprecated
1361+
===================
1362+
1363+
To be removed in 0.19
1364+
---------------------
1365+
1366+
.. autosummary::
1367+
:toctree: generated/
1368+
:template: deprecated_class.rst
1369+
1370+
lda.LDA
1371+
qda.QDA
1372+
1373+
.. autosummary::
1374+
:toctree: generated/
1375+
:template: deprecated_function.rst
1376+
1377+
datasets.load_lfw_pairs
1378+
datasets.load_lfw_people
1379+
1380+
1381+
To be removed in 0.20
1382+
---------------------
1383+
1384+
.. autosummary::
1385+
:toctree: generated/
1386+
:template: deprecated_class.rst
1387+
1388+
grid_search.ParameterGrid
1389+
grid_search.ParameterSampler
1390+
grid_search.GridSearchCV
1391+
grid_search.RandomizedSearchCV
1392+
cross_validation.LeaveOneOut
1393+
cross_validation.LeavePOut
1394+
cross_validation.KFold
1395+
cross_validation.LabelKFold
1396+
cross_validation.LeaveOneLabelOut
1397+
cross_validation.LeavePLabelOut
1398+
cross_validation.LabelShuffleSplit
1399+
cross_validation.StratifiedKFold
1400+
cross_validation.ShuffleSplit
1401+
cross_validation.StratifiedShuffleSplit
1402+
cross_validation.PredefinedSplit
1403+
decomposition.RandomizedPCA
1404+
gaussian_process.GaussianProcess
1405+
mixture.GMM
1406+
mixture.DPGMM
1407+
mixture.VBGMM
1408+
1409+
1410+
.. autosummary::
1411+
:toctree: generated/
1412+
:template: deprecated_function.rst
1413+
1414+
grid_search.fit_grid_point
1415+
learning_curve.learning_curve
1416+
learning_curve.validation_curve
1417+
cross_validation.cross_val_predict
1418+
cross_validation.cross_val_score
1419+
cross_validation.check_cv
1420+
cross_validation.permutation_test_score
1421+
cross_validation.train_test_split

doc/templates/deprecated_class.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:mod:`{{module}}`.{{objname}}
2+
{{ underline }}==============
3+
4+
.. meta::
5+
:robots: noindex
6+
7+
.. warning::
8+
**DEPRECATED**
9+
10+
11+
.. currentmodule:: {{ module }}
12+
13+
.. autoclass:: {{ objname }}
14+
15+
{% block methods %}
16+
.. automethod:: __init__
17+
{% endblock %}
18+
19+
.. include:: {{module}}.{{objname}}.examples
20+
21+
.. raw:: html
22+
23+
<div class="clearer"></div>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
:mod:`{{module}}`.{{objname}}
2+
{{ underline }}===============
3+
4+
.. meta::
5+
:robots: noindex
6+
7+
.. warning::
8+
**DEPRECATED**
9+
10+
11+
.. currentmodule:: {{ module }}
12+
13+
.. autoclass:: {{ objname }}
14+
15+
{% block methods %}
16+
.. automethod:: __init__
17+
.. automethod:: __call__
18+
{% endblock %}
19+
20+
.. include:: {{module}}.{{objname}}.examples
21+
22+
.. raw:: html
23+
24+
<div class="clearer"></div>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
:mod:`{{module}}`.{{objname}}
2+
{{ underline }}==============
3+
4+
.. meta::
5+
:robots: noindex
6+
7+
.. warning::
8+
**DEPRECATED**
9+
10+
11+
.. currentmodule:: {{ module }}
12+
13+
.. autoclass:: {{ objname }}
14+
15+
.. include:: {{module}}.{{objname}}.examples
16+
17+
.. raw:: html
18+
19+
<div class="clearer"></div>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
:mod:`{{module}}`.{{objname}}
2+
{{ underline }}====================
3+
4+
.. meta::
5+
:robots: noindex
6+
7+
.. warning::
8+
**DEPRECATED**
9+
10+
11+
.. currentmodule:: {{ module }}
12+
13+
.. autofunction:: {{ objname }}
14+
15+
.. include:: {{module}}.{{objname}}.examples
16+
17+
.. raw:: html
18+
19+
<div class="clearer"></div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
for f in [^d]*; do (head -n2 < $f; echo '
3+
.. meta::
4+
:robots: noindex
5+
6+
.. warning::
7+
**DEPRECATED**
8+
'; tail -n+3 $f) > deprecated_$f; done

doc/themes/scikit-learn/static/nature.css_t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ div.admonition {
603603
-moz-border-radius: 4px;
604604
}
605605

606-
div.warning {
606+
div.warning, div.deprecated {
607607
color: #b94a48;
608608
background-color: #F3E5E5;
609609
border: 1px solid #eed3d7;

sklearn/cross_validation.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def _empty_mask(self):
109109
class LeaveOneOut(_PartitionIterator):
110110
"""Leave-One-Out cross validation iterator.
111111
112+
.. deprecated:: 0.18
113+
This module will be removed in 0.20.
114+
Use :class:`sklearn.model_selection.LeaveOneOut` instead.
115+
112116
Provides train/test indices to split data in train test sets. Each
113117
sample is used once as a test set (singleton) while the remaining
114118
samples form the training set.
@@ -171,6 +175,10 @@ def __len__(self):
171175
class LeavePOut(_PartitionIterator):
172176
"""Leave-P-Out cross validation iterator
173177
178+
.. deprecated:: 0.18
179+
This module will be removed in 0.20.
180+
Use :class:`sklearn.model_selection.LeavePOut` instead.
181+
174182
Provides train/test indices to split data in train test sets. This results
175183
in testing on all distinct samples of size p, while the remaining n - p
176184
samples form the training set in each iteration.
@@ -266,6 +274,10 @@ def __init__(self, n, n_folds, shuffle, random_state):
266274
class KFold(_BaseKFold):
267275
"""K-Folds cross validation iterator.
268276
277+
.. deprecated:: 0.18
278+
This module will be removed in 0.20.
279+
Use :class:`sklearn.model_selection.KFold` instead.
280+
269281
Provides train/test indices to split data in train test sets. Split
270282
dataset into k consecutive folds (without shuffling by default).
271283
@@ -357,6 +369,10 @@ def __len__(self):
357369
class LabelKFold(_BaseKFold):
358370
"""K-fold iterator variant with non-overlapping labels.
359371
372+
.. deprecated:: 0.18
373+
This module will be removed in 0.20.
374+
Use :class:`sklearn.model_selection.GroupKFold` instead.
375+
360376
The same label will not appear in two different folds (the number of
361377
distinct labels has to be at least equal to the number of folds).
362378
@@ -459,6 +475,10 @@ def __len__(self):
459475
class StratifiedKFold(_BaseKFold):
460476
"""Stratified K-Folds cross validation iterator
461477
478+
.. deprecated:: 0.18
479+
This module will be removed in 0.20.
480+
Use :class:`sklearn.model_selection.StratifiedKFold` instead.
481+
462482
Provides train/test indices to split data in train test sets.
463483
464484
This cross-validation object is a variation of KFold that
@@ -581,6 +601,10 @@ def __len__(self):
581601
class LeaveOneLabelOut(_PartitionIterator):
582602
"""Leave-One-Label_Out cross-validation iterator
583603
604+
.. deprecated:: 0.18
605+
This module will be removed in 0.20.
606+
Use :class:`sklearn.model_selection.LeaveOneGroupOut` instead.
607+
584608
Provides train/test indices to split data according to a third-party
585609
provided label. This label information can be used to encode arbitrary
586610
domain specific stratifications of the samples as integers.
@@ -651,6 +675,10 @@ def __len__(self):
651675
class LeavePLabelOut(_PartitionIterator):
652676
"""Leave-P-Label_Out cross-validation iterator
653677
678+
.. deprecated:: 0.18
679+
This module will be removed in 0.20.
680+
Use :class:`sklearn.model_selection.LeavePGroupsOut` instead.
681+
654682
Provides train/test indices to split data according to a third-party
655683
provided label. This label information can be used to encode arbitrary
656684
domain specific stratifications of the samples as integers.
@@ -762,6 +790,10 @@ def _iter_indices(self):
762790
class ShuffleSplit(BaseShuffleSplit):
763791
"""Random permutation cross-validation iterator.
764792
793+
.. deprecated:: 0.18
794+
This module will be removed in 0.20.
795+
Use :class:`sklearn.model_selection.ShuffleSplit` instead.
796+
765797
Yields indices to split data into training and test sets.
766798
767799
Note: contrary to other cross-validation strategies, random splits
@@ -963,6 +995,10 @@ def _approximate_mode(class_counts, n_draws, rng):
963995
class StratifiedShuffleSplit(BaseShuffleSplit):
964996
"""Stratified ShuffleSplit cross validation iterator
965997
998+
.. deprecated:: 0.18
999+
This module will be removed in 0.20.
1000+
Use :class:`sklearn.model_selection.StratifiedShuffleSplit` instead.
1001+
9661002
Provides train/test indices to split data in train test sets.
9671003
9681004
This cross-validation object is a merge of StratifiedKFold and
@@ -1085,6 +1121,10 @@ def __len__(self):
10851121
class PredefinedSplit(_PartitionIterator):
10861122
"""Predefined split cross validation iterator
10871123
1124+
.. deprecated:: 0.18
1125+
This module will be removed in 0.20.
1126+
Use :class:`sklearn.model_selection.PredefinedSplit` instead.
1127+
10881128
Splits the data into training/test set folds according to a predefined
10891129
scheme. Each sample can be assigned to at most one test set fold, as
10901130
specified by the user through the ``test_fold`` parameter.
@@ -1140,6 +1180,10 @@ def __len__(self):
11401180
class LabelShuffleSplit(ShuffleSplit):
11411181
"""Shuffle-Labels-Out cross-validation iterator
11421182
1183+
.. deprecated:: 0.18
1184+
This module will be removed in 0.20.
1185+
Use :class:`sklearn.model_selection.GroupShuffleSplit` instead.
1186+
11431187
Provides randomized train/test indices to split data according to a
11441188
third-party provided label. This label information can be used to encode
11451189
arbitrary domain specific stratifications of the samples as integers.
@@ -1241,6 +1285,10 @@ def cross_val_predict(estimator, X, y=None, cv=None, n_jobs=1,
12411285
verbose=0, fit_params=None, pre_dispatch='2*n_jobs'):
12421286
"""Generate cross-validated estimates for each input data point
12431287
1288+
.. deprecated:: 0.18
1289+
This module will be removed in 0.20.
1290+
Use :func:`sklearn.model_selection.cross_val_predict` instead.
1291+
12441292
Read more in the :ref:`User Guide <cross_validation>`.
12451293
12461294
Parameters
@@ -1421,6 +1469,10 @@ def cross_val_score(estimator, X, y=None, scoring=None, cv=None, n_jobs=1,
14211469
verbose=0, fit_params=None, pre_dispatch='2*n_jobs'):
14221470
"""Evaluate a score by cross-validation
14231471
1472+
.. deprecated:: 0.18
1473+
This module will be removed in 0.20.
1474+
Use :func:`sklearn.model_selection.cross_val_score` instead.
1475+
14241476
Read more in the :ref:`User Guide <cross_validation>`.
14251477
14261478
Parameters
@@ -1724,6 +1776,10 @@ def _shuffle(y, labels, random_state):
17241776
def check_cv(cv, X=None, y=None, classifier=False):
17251777
"""Input checker utility for building a CV in a user friendly way.
17261778
1779+
.. deprecated:: 0.18
1780+
This module will be removed in 0.20.
1781+
Use :func:`sklearn.model_selection.check_cv` instead.
1782+
17271783
Parameters
17281784
----------
17291785
cv : int, cross-validation generator or an iterable, optional
@@ -1781,6 +1837,10 @@ def permutation_test_score(estimator, X, y, cv=None,
17811837
random_state=0, verbose=0, scoring=None):
17821838
"""Evaluate the significance of a cross-validated score with permutations
17831839
1840+
.. deprecated:: 0.18
1841+
This module will be removed in 0.20.
1842+
Use :func:`sklearn.model_selection.permutation_test_score` instead.
1843+
17841844
Read more in the :ref:`User Guide <cross_validation>`.
17851845
17861846
Parameters
@@ -1882,6 +1942,10 @@ def permutation_test_score(estimator, X, y, cv=None,
18821942
def train_test_split(*arrays, **options):
18831943
"""Split arrays or matrices into random train and test subsets
18841944
1945+
.. deprecated:: 0.18
1946+
This module will be removed in 0.20.
1947+
Use :func:`sklearn.model_selection.train_test_split` instead.
1948+
18851949
Quick utility that wraps input validation and
18861950
``next(iter(ShuffleSplit(n_samples)))`` and application to input
18871951
data into a single call for splitting (and optionally subsampling)

0 commit comments

Comments
 (0)