From 6e50c8f35e67719e5b528b66bfe75444ec0008ed Mon Sep 17 00:00:00 2001 From: waterponey <prosper.burq@gmail.com> Date: Sun, 30 Oct 2016 16:04:35 +0100 Subject: [PATCH] [MRG+2] DOC framework for keeping API refs for deprecated classes/funcs (#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 --- doc/modules/classes.rst | 74 ++++++++++++++++++- doc/templates/deprecated_class.rst | 23 ++++++ doc/templates/deprecated_class_with_call.rst | 24 ++++++ .../deprecated_class_without_init.rst | 19 +++++ doc/templates/deprecated_function.rst | 19 +++++ doc/templates/generate_deprecated.sh | 8 ++ doc/themes/scikit-learn/static/nature.css_t | 2 +- sklearn/cross_validation.py | 64 ++++++++++++++++ sklearn/datasets/lfw.py | 16 +++- sklearn/decomposition/pca.py | 6 ++ sklearn/discriminant_analysis.py | 6 -- sklearn/gaussian_process/gaussian_process.py | 5 +- sklearn/grid_search.py | 19 +++++ sklearn/lda.py | 16 +++- sklearn/learning_curve.py | 8 ++ sklearn/mixture/dpgmm.py | 15 ++++ sklearn/mixture/gmm.py | 9 +++ sklearn/qda.py | 16 +++- sklearn/tests/test_discriminant_analysis.py | 4 +- 19 files changed, 336 insertions(+), 17 deletions(-) create mode 100644 doc/templates/deprecated_class.rst create mode 100644 doc/templates/deprecated_class_with_call.rst create mode 100644 doc/templates/deprecated_class_without_init.rst create mode 100644 doc/templates/deprecated_function.rst create mode 100755 doc/templates/generate_deprecated.sh diff --git a/doc/modules/classes.rst b/doc/modules/classes.rst index d3fb1615ef..a4d893bafb 100644 --- a/doc/modules/classes.rst +++ b/doc/modules/classes.rst @@ -186,6 +186,7 @@ Splitter Functions :template: function.rst model_selection.train_test_split + model_selection.check_cv Hyper-parameter optimizers -------------------------- @@ -201,6 +202,13 @@ Hyper-parameter optimizers model_selection.ParameterGrid model_selection.ParameterSampler + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + model_selection.fit_grid_point + Model validation ---------------- @@ -315,7 +323,6 @@ Samples generator decomposition.PCA decomposition.IncrementalPCA decomposition.ProjectedGradientNMF - decomposition.RandomizedPCA decomposition.KernelPCA decomposition.FactorAnalysis decomposition.FastICA @@ -560,7 +567,6 @@ From text gaussian_process.GaussianProcessRegressor gaussian_process.GaussianProcessClassifier - gaussian_process.GaussianProcess Kernels: @@ -1349,3 +1355,67 @@ Low-level methods utils.estimator_checks.check_estimator utils.resample utils.shuffle + + +Recently deprecated +=================== + +To be removed in 0.19 +--------------------- + +.. autosummary:: + :toctree: generated/ + :template: deprecated_class.rst + + lda.LDA + qda.QDA + +.. autosummary:: + :toctree: generated/ + :template: deprecated_function.rst + + datasets.load_lfw_pairs + datasets.load_lfw_people + + +To be removed in 0.20 +--------------------- + +.. autosummary:: + :toctree: generated/ + :template: deprecated_class.rst + + grid_search.ParameterGrid + grid_search.ParameterSampler + grid_search.GridSearchCV + grid_search.RandomizedSearchCV + cross_validation.LeaveOneOut + cross_validation.LeavePOut + cross_validation.KFold + cross_validation.LabelKFold + cross_validation.LeaveOneLabelOut + cross_validation.LeavePLabelOut + cross_validation.LabelShuffleSplit + cross_validation.StratifiedKFold + cross_validation.ShuffleSplit + cross_validation.StratifiedShuffleSplit + cross_validation.PredefinedSplit + decomposition.RandomizedPCA + gaussian_process.GaussianProcess + mixture.GMM + mixture.DPGMM + mixture.VBGMM + + +.. autosummary:: + :toctree: generated/ + :template: deprecated_function.rst + + grid_search.fit_grid_point + learning_curve.learning_curve + learning_curve.validation_curve + cross_validation.cross_val_predict + cross_validation.cross_val_score + cross_validation.check_cv + cross_validation.permutation_test_score + cross_validation.train_test_split \ No newline at end of file diff --git a/doc/templates/deprecated_class.rst b/doc/templates/deprecated_class.rst new file mode 100644 index 0000000000..857e2c28ce --- /dev/null +++ b/doc/templates/deprecated_class.rst @@ -0,0 +1,23 @@ +:mod:`{{module}}`.{{objname}} +{{ underline }}============== + +.. meta:: + :robots: noindex + +.. warning:: + **DEPRECATED** + + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + + {% block methods %} + .. automethod:: __init__ + {% endblock %} + +.. include:: {{module}}.{{objname}}.examples + +.. raw:: html + + <div class="clearer"></div> diff --git a/doc/templates/deprecated_class_with_call.rst b/doc/templates/deprecated_class_with_call.rst new file mode 100644 index 0000000000..a04efcb80b --- /dev/null +++ b/doc/templates/deprecated_class_with_call.rst @@ -0,0 +1,24 @@ +:mod:`{{module}}`.{{objname}} +{{ underline }}=============== + +.. meta:: + :robots: noindex + +.. warning:: + **DEPRECATED** + + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + + {% block methods %} + .. automethod:: __init__ + .. automethod:: __call__ + {% endblock %} + +.. include:: {{module}}.{{objname}}.examples + +.. raw:: html + + <div class="clearer"></div> diff --git a/doc/templates/deprecated_class_without_init.rst b/doc/templates/deprecated_class_without_init.rst new file mode 100644 index 0000000000..c019992493 --- /dev/null +++ b/doc/templates/deprecated_class_without_init.rst @@ -0,0 +1,19 @@ +:mod:`{{module}}`.{{objname}} +{{ underline }}============== + +.. meta:: + :robots: noindex + +.. warning:: + **DEPRECATED** + + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + +.. include:: {{module}}.{{objname}}.examples + +.. raw:: html + + <div class="clearer"></div> diff --git a/doc/templates/deprecated_function.rst b/doc/templates/deprecated_function.rst new file mode 100644 index 0000000000..6d13ac6aca --- /dev/null +++ b/doc/templates/deprecated_function.rst @@ -0,0 +1,19 @@ +:mod:`{{module}}`.{{objname}} +{{ underline }}==================== + +.. meta:: + :robots: noindex + +.. warning:: + **DEPRECATED** + + +.. currentmodule:: {{ module }} + +.. autofunction:: {{ objname }} + +.. include:: {{module}}.{{objname}}.examples + +.. raw:: html + + <div class="clearer"></div> diff --git a/doc/templates/generate_deprecated.sh b/doc/templates/generate_deprecated.sh new file mode 100755 index 0000000000..a7301fb5dc --- /dev/null +++ b/doc/templates/generate_deprecated.sh @@ -0,0 +1,8 @@ +#!/bin/bash +for f in [^d]*; do (head -n2 < $f; echo ' +.. meta:: + :robots: noindex + +.. warning:: + **DEPRECATED** +'; tail -n+3 $f) > deprecated_$f; done diff --git a/doc/themes/scikit-learn/static/nature.css_t b/doc/themes/scikit-learn/static/nature.css_t index 4c318b514a..593cb01ce6 100644 --- a/doc/themes/scikit-learn/static/nature.css_t +++ b/doc/themes/scikit-learn/static/nature.css_t @@ -603,7 +603,7 @@ div.admonition { -moz-border-radius: 4px; } -div.warning { +div.warning, div.deprecated { color: #b94a48; background-color: #F3E5E5; border: 1px solid #eed3d7; diff --git a/sklearn/cross_validation.py b/sklearn/cross_validation.py index 010f7106a4..65960aaa9e 100644 --- a/sklearn/cross_validation.py +++ b/sklearn/cross_validation.py @@ -109,6 +109,10 @@ class _PartitionIterator(with_metaclass(ABCMeta)): class LeaveOneOut(_PartitionIterator): """Leave-One-Out cross validation iterator. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.LeaveOneOut` instead. + Provides train/test indices to split data in train test sets. Each sample is used once as a test set (singleton) while the remaining samples form the training set. @@ -171,6 +175,10 @@ class LeaveOneOut(_PartitionIterator): class LeavePOut(_PartitionIterator): """Leave-P-Out cross validation iterator + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.LeavePOut` instead. + Provides train/test indices to split data in train test sets. This results in testing on all distinct samples of size p, while the remaining n - p samples form the training set in each iteration. @@ -266,6 +274,10 @@ class _BaseKFold(with_metaclass(ABCMeta, _PartitionIterator)): class KFold(_BaseKFold): """K-Folds cross validation iterator. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.KFold` instead. + Provides train/test indices to split data in train test sets. Split dataset into k consecutive folds (without shuffling by default). @@ -357,6 +369,10 @@ class KFold(_BaseKFold): class LabelKFold(_BaseKFold): """K-fold iterator variant with non-overlapping labels. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.GroupKFold` instead. + The same label will not appear in two different folds (the number of distinct labels has to be at least equal to the number of folds). @@ -459,6 +475,10 @@ class LabelKFold(_BaseKFold): class StratifiedKFold(_BaseKFold): """Stratified K-Folds cross validation iterator + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.StratifiedKFold` instead. + Provides train/test indices to split data in train test sets. This cross-validation object is a variation of KFold that @@ -581,6 +601,10 @@ class StratifiedKFold(_BaseKFold): class LeaveOneLabelOut(_PartitionIterator): """Leave-One-Label_Out cross-validation iterator + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.LeaveOneGroupOut` instead. + Provides train/test indices to split data according to a third-party provided label. This label information can be used to encode arbitrary domain specific stratifications of the samples as integers. @@ -651,6 +675,10 @@ class LeaveOneLabelOut(_PartitionIterator): class LeavePLabelOut(_PartitionIterator): """Leave-P-Label_Out cross-validation iterator + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.LeavePGroupsOut` instead. + Provides train/test indices to split data according to a third-party provided label. This label information can be used to encode arbitrary domain specific stratifications of the samples as integers. @@ -762,6 +790,10 @@ class BaseShuffleSplit(with_metaclass(ABCMeta)): class ShuffleSplit(BaseShuffleSplit): """Random permutation cross-validation iterator. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.ShuffleSplit` instead. + Yields indices to split data into training and test sets. Note: contrary to other cross-validation strategies, random splits @@ -963,6 +995,10 @@ def _approximate_mode(class_counts, n_draws, rng): class StratifiedShuffleSplit(BaseShuffleSplit): """Stratified ShuffleSplit cross validation iterator + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.StratifiedShuffleSplit` instead. + Provides train/test indices to split data in train test sets. This cross-validation object is a merge of StratifiedKFold and @@ -1085,6 +1121,10 @@ class StratifiedShuffleSplit(BaseShuffleSplit): class PredefinedSplit(_PartitionIterator): """Predefined split cross validation iterator + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.PredefinedSplit` instead. + Splits the data into training/test set folds according to a predefined scheme. Each sample can be assigned to at most one test set fold, as specified by the user through the ``test_fold`` parameter. @@ -1140,6 +1180,10 @@ class PredefinedSplit(_PartitionIterator): class LabelShuffleSplit(ShuffleSplit): """Shuffle-Labels-Out cross-validation iterator + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.GroupShuffleSplit` instead. + Provides randomized train/test indices to split data according to a third-party provided label. This label information can be used to encode 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, verbose=0, fit_params=None, pre_dispatch='2*n_jobs'): """Generate cross-validated estimates for each input data point + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :func:`sklearn.model_selection.cross_val_predict` instead. + Read more in the :ref:`User Guide <cross_validation>`. Parameters @@ -1421,6 +1469,10 @@ def cross_val_score(estimator, X, y=None, scoring=None, cv=None, n_jobs=1, verbose=0, fit_params=None, pre_dispatch='2*n_jobs'): """Evaluate a score by cross-validation + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :func:`sklearn.model_selection.cross_val_score` instead. + Read more in the :ref:`User Guide <cross_validation>`. Parameters @@ -1724,6 +1776,10 @@ def _shuffle(y, labels, random_state): def check_cv(cv, X=None, y=None, classifier=False): """Input checker utility for building a CV in a user friendly way. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :func:`sklearn.model_selection.check_cv` instead. + Parameters ---------- cv : int, cross-validation generator or an iterable, optional @@ -1781,6 +1837,10 @@ def permutation_test_score(estimator, X, y, cv=None, random_state=0, verbose=0, scoring=None): """Evaluate the significance of a cross-validated score with permutations + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :func:`sklearn.model_selection.permutation_test_score` instead. + Read more in the :ref:`User Guide <cross_validation>`. Parameters @@ -1882,6 +1942,10 @@ permutation_test_score.__test__ = False # to avoid a pb with nosetests def train_test_split(*arrays, **options): """Split arrays or matrices into random train and test subsets + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :func:`sklearn.model_selection.train_test_split` instead. + Quick utility that wraps input validation and ``next(iter(ShuffleSplit(n_samples)))`` and application to input data into a single call for splitting (and optionally subsampling) diff --git a/sklearn/datasets/lfw.py b/sklearn/datasets/lfw.py index af6503f14d..e944e65867 100644 --- a/sklearn/datasets/lfw.py +++ b/sklearn/datasets/lfw.py @@ -380,7 +380,13 @@ def _fetch_lfw_pairs(index_file_path, data_folder_path, slice_=None, "be removed in 0.19." "Use fetch_lfw_people(download_if_missing=False) instead.") def load_lfw_people(download_if_missing=False, **kwargs): - """Alias for fetch_lfw_people(download_if_missing=False) + """ + Alias for fetch_lfw_people(download_if_missing=False) + + .. deprecated:: 0.17 + This function will be removed in 0.19. + Use :func:`sklearn.datasets.fetch_lfw_people` with parameter + ``download_if_missing=False`` instead. Check fetch_lfw_people.__doc__ for the documentation and parameter list. """ @@ -509,7 +515,13 @@ def fetch_lfw_pairs(subset='train', data_home=None, funneled=True, resize=0.5, "be removed in 0.19." "Use fetch_lfw_pairs(download_if_missing=False) instead.") def load_lfw_pairs(download_if_missing=False, **kwargs): - """Alias for fetch_lfw_pairs(download_if_missing=False) + """ + Alias for fetch_lfw_pairs(download_if_missing=False) + + .. deprecated:: 0.17 + This function will be removed in 0.19. + Use :func:`sklearn.datasets.fetch_lfw_pairs` with parameter + ``download_if_missing=False`` instead. Check fetch_lfw_pairs.__doc__ for the documentation and parameter list. """ diff --git a/sklearn/decomposition/pca.py b/sklearn/decomposition/pca.py index 65bce86840..f9a4142ee8 100644 --- a/sklearn/decomposition/pca.py +++ b/sklearn/decomposition/pca.py @@ -554,6 +554,12 @@ class PCA(_BasePCA): class RandomizedPCA(BaseEstimator, TransformerMixin): """Principal component analysis (PCA) using randomized SVD + .. deprecated:: 0.18 + This class will be removed in 0.20. + Use :class:`PCA` with parameter svd_solver 'randomized' instead. + The new implementation DOES NOT store whiten ``components_``. + Apply transform to get them. + Linear dimensionality reduction using approximated Singular Value Decomposition of the data and keeping only the most significant singular vectors to project the data to a lower dimensional space. diff --git a/sklearn/discriminant_analysis.py b/sklearn/discriminant_analysis.py index d6675f2fe2..628314a013 100644 --- a/sklearn/discriminant_analysis.py +++ b/sklearn/discriminant_analysis.py @@ -143,9 +143,6 @@ class LinearDiscriminantAnalysis(BaseEstimator, LinearClassifierMixin, .. versionadded:: 0.17 *LinearDiscriminantAnalysis*. - .. versionchanged:: 0.17 - Deprecated :class:`lda.LDA` have been moved to :class:`LinearDiscriminantAnalysis`. - Read more in the :ref:`User Guide <lda_qda>`. Parameters @@ -562,9 +559,6 @@ class QuadraticDiscriminantAnalysis(BaseEstimator, ClassifierMixin): .. versionadded:: 0.17 *QuadraticDiscriminantAnalysis* - .. versionchanged:: 0.17 - Deprecated :class:`qda.QDA` have been moved to :class:`QuadraticDiscriminantAnalysis`. - Read more in the :ref:`User Guide <lda_qda>`. Parameters diff --git a/sklearn/gaussian_process/gaussian_process.py b/sklearn/gaussian_process/gaussian_process.py index 9e78ba2ea7..c521cb5b52 100644 --- a/sklearn/gaussian_process/gaussian_process.py +++ b/sklearn/gaussian_process/gaussian_process.py @@ -64,8 +64,9 @@ def l1_cross_distances(X): class GaussianProcess(BaseEstimator, RegressorMixin): """The legacy Gaussian Process model class. - Note that this class was deprecated in version 0.18 and will be - removed in 0.20. Use the GaussianProcessRegressor instead. + .. deprecated:: 0.18 + This class will be removed in 0.20. + Use the :class:`GaussianProcessRegressor` instead. Read more in the :ref:`User Guide <gaussian_process>`. diff --git a/sklearn/grid_search.py b/sklearn/grid_search.py index f49d7e0485..6c0101a559 100644 --- a/sklearn/grid_search.py +++ b/sklearn/grid_search.py @@ -46,6 +46,10 @@ warnings.warn("This module was deprecated in version 0.18 in favor of the " class ParameterGrid(object): """Grid of parameters with a discrete number of values for each. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.ParameterGrid` instead. + Can be used to iterate over parameter value combinations with the Python built-in function iter. @@ -165,6 +169,10 @@ class ParameterGrid(object): class ParameterSampler(object): """Generator on parameters sampled from given distributions. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.ParameterSampler` instead. + Non-deterministic iterable over random candidate combinations for hyper- parameter search. If all parameters are presented as a list, sampling without replacement is performed. If at least one parameter @@ -265,6 +273,10 @@ def fit_grid_point(X, y, estimator, parameters, train, test, scorer, verbose, error_score='raise', **fit_params): """Run fit on one set of parameters. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :func:`sklearn.model_selection.fit_grid_point` instead. + Parameters ---------- X : array-like, sparse matrix or list @@ -618,6 +630,10 @@ class BaseSearchCV(six.with_metaclass(ABCMeta, BaseEstimator, class GridSearchCV(BaseSearchCV): """Exhaustive search over specified parameter values for an estimator. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.GridSearchCV` instead. + Important members are fit, predict. GridSearchCV implements a "fit" and a "score" method. @@ -820,6 +836,9 @@ class GridSearchCV(BaseSearchCV): class RandomizedSearchCV(BaseSearchCV): """Randomized search on hyper parameters. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :class:`sklearn.model_selection.RandomizedSearchCV` instead. RandomizedSearchCV implements a "fit" and a "score" method. It also implements "predict", "predict_proba", "decision_function", diff --git a/sklearn/lda.py b/sklearn/lda.py index 8a488ecc7e..9c3959b6bc 100644 --- a/sklearn/lda.py +++ b/sklearn/lda.py @@ -1,6 +1,20 @@ import warnings +from .discriminant_analysis import LinearDiscriminantAnalysis as _LDA + warnings.warn("lda.LDA has been moved to " "discriminant_analysis.LinearDiscriminantAnalysis " "in 0.17 and will be removed in 0.19", DeprecationWarning) -from .discriminant_analysis import LinearDiscriminantAnalysis as LDA + +class LDA(_LDA): + """ + Alias for + :class:`sklearn.discriminant_analysis.LinearDiscriminantAnalysis`. + + .. deprecated:: 0.17 + This class will be removed in 0.19. + Use + :class:`sklearn.discriminant_analysis.LinearDiscriminantAnalysis` + instead. + """ + pass diff --git a/sklearn/learning_curve.py b/sklearn/learning_curve.py index 1642b9a7c4..59d55cad3e 100644 --- a/sklearn/learning_curve.py +++ b/sklearn/learning_curve.py @@ -32,6 +32,10 @@ def learning_curve(estimator, X, y, train_sizes=np.linspace(0.1, 1.0, 5), error_score='raise'): """Learning curve. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :func:`sklearn.model_selection.learning_curve` instead. + Determines cross-validated training and test scores for different training set sizes. @@ -259,6 +263,10 @@ def validation_curve(estimator, X, y, param_name, param_range, cv=None, scoring=None, n_jobs=1, pre_dispatch="all", verbose=0): """Validation curve. + .. deprecated:: 0.18 + This module will be removed in 0.20. + Use :func:`sklearn.model_selection.validation_curve` instead. + Determine training and test scores for varying parameter values. Compute scores for an estimator with different values of a specified diff --git a/sklearn/mixture/dpgmm.py b/sklearn/mixture/dpgmm.py index 1b119b8b72..bbbf0b9e21 100644 --- a/sklearn/mixture/dpgmm.py +++ b/sklearn/mixture/dpgmm.py @@ -629,6 +629,16 @@ class _DPGMMBase(_GMMBase): "instead. DPGMM is deprecated in 0.18 and will be " "removed in 0.20.") class DPGMM(_DPGMMBase): + """Dirichlet Process Gaussian Mixture Models + + .. deprecated:: 0.18 + This class will be removed in 0.20. + Use :class:`sklearn.mixture.BayesianGaussianMixture` with + parameter ``weight_concentration_prior_type='dirichlet_process'`` + instead. + + """ + def __init__(self, n_components=1, covariance_type='diag', alpha=1.0, random_state=None, tol=1e-3, verbose=0, min_covar=None, n_iter=10, params='wmc', init_params='wmc'): @@ -647,6 +657,11 @@ class DPGMM(_DPGMMBase): class VBGMM(_DPGMMBase): """Variational Inference for the Gaussian Mixture Model + .. deprecated:: 0.18 + This class will be removed in 0.20. + Use :class:`sklearn.mixture.BayesianGaussianMixture` with parameter + ``weight_concentration_prior_type='dirichlet_distribution'`` instead. + Variational inference for a Gaussian mixture model probability distribution. This class allows for easy and efficient inference of an approximate posterior distribution over the parameters of a diff --git a/sklearn/mixture/gmm.py b/sklearn/mixture/gmm.py index 588882cefe..69f182b142 100644 --- a/sklearn/mixture/gmm.py +++ b/sklearn/mixture/gmm.py @@ -670,6 +670,15 @@ class _GMMBase(BaseEstimator): @deprecated("The class GMM is deprecated in 0.18 and will be " " removed in 0.20. Use class GaussianMixture instead.") class GMM(_GMMBase): + """ + Legacy Gaussian Mixture Model + + .. deprecated:: 0.18 + This class will be removed in 0.20. + Use :class:`sklearn.mixture.GaussianMixture` instead. + + """ + def __init__(self, n_components=1, covariance_type='diag', random_state=None, tol=1e-3, min_covar=1e-3, n_iter=100, n_init=1, params='wmc', init_params='wmc', diff --git a/sklearn/qda.py b/sklearn/qda.py index 069afb629c..604d6a919d 100644 --- a/sklearn/qda.py +++ b/sklearn/qda.py @@ -1,6 +1,20 @@ import warnings +from .discriminant_analysis import QuadraticDiscriminantAnalysis as _QDA + warnings.warn("qda.QDA has been moved to " "discriminant_analysis.QuadraticDiscriminantAnalysis " "in 0.17 and will be removed in 0.19.", DeprecationWarning) -from .discriminant_analysis import QuadraticDiscriminantAnalysis as QDA + +class QDA(_QDA): + """ + Alias for + :class:`sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis`. + + .. deprecated:: 0.17 + This class will be removed in 0.19. + Use + :class:`sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis` + instead. + """ + pass diff --git a/sklearn/tests/test_discriminant_analysis.py b/sklearn/tests/test_discriminant_analysis.py index 64e4769670..d1049fa6de 100644 --- a/sklearn/tests/test_discriminant_analysis.py +++ b/sklearn/tests/test_discriminant_analysis.py @@ -329,7 +329,7 @@ def test_deprecated_lda_qda_deprecation(): return sklearn.lda lda = assert_warns(DeprecationWarning, import_lda_module) - assert lda.LDA is LinearDiscriminantAnalysis + assert isinstance(lda.LDA(), LinearDiscriminantAnalysis) def import_qda_module(): import sklearn.qda @@ -339,7 +339,7 @@ def test_deprecated_lda_qda_deprecation(): return sklearn.qda qda = assert_warns(DeprecationWarning, import_qda_module) - assert qda.QDA is QuadraticDiscriminantAnalysis + assert isinstance(qda.QDA(), QuadraticDiscriminantAnalysis) def test_covariance(): -- GitLab