From dab1c85934a9e06c6f9ea429b042f02b69c8722d Mon Sep 17 00:00:00 2001 From: brigi Date: Sat, 25 Jan 2020 14:54:31 +0100 Subject: [PATCH 1/3] Versionlabels added to v0.18 (#wimlds) --- sklearn/cluster/_kmeans.py | 3 +++ sklearn/ensemble/_voting.py | 3 +++ sklearn/feature_selection/_rfe.py | 2 ++ sklearn/feature_selection/_univariate_selection.py | 4 ++++ sklearn/linear_model/_ransac.py | 4 ++++ sklearn/metrics/_classification.py | 9 +++++++-- sklearn/metrics/cluster/_supervised.py | 2 ++ sklearn/model_selection/_split.py | 2 ++ sklearn/multioutput.py | 2 ++ sklearn/preprocessing/_function_transformer.py | 4 ++++ sklearn/svm/_classes.py | 4 ++++ 11 files changed, 37 insertions(+), 2 deletions(-) diff --git a/sklearn/cluster/_kmeans.py b/sklearn/cluster/_kmeans.py index 21a604bed3eb5..42c67047cd1c8 100644 --- a/sklearn/cluster/_kmeans.py +++ b/sklearn/cluster/_kmeans.py @@ -834,6 +834,9 @@ class KMeans(TransformerMixin, ClusterMixin, BaseEstimator): For now "auto" (kept for backward compatibiliy) chooses "elkan" but it might change in the future for a better heuristic. + .. versionchanged:: 0.18 + Added ''algorithm="elkan"'' implementing Elkan's fast K-Means algorithm + Attributes ---------- cluster_centers_ : ndarray of shape (n_clusters, n_features) diff --git a/sklearn/ensemble/_voting.py b/sklearn/ensemble/_voting.py index b044cb68e5151..3d49e5f6967c1 100644 --- a/sklearn/ensemble/_voting.py +++ b/sklearn/ensemble/_voting.py @@ -141,6 +141,8 @@ class VotingClassifier(ClassifierMixin, _BaseVoting): ``-1`` means using all processors. See :term:`Glossary ` for more details. + .. versionadded:: 0.18 + flatten_transform : bool, default=True Affects shape of transform output only when voting='soft' If voting='soft' and flatten_transform=True, transform method returns @@ -231,6 +233,7 @@ def fit(self, X, y, sample_weight=None): Sample weights. If None, then samples are equally weighted. Note that this is supported only if all underlying estimators support sample weights. + .. versionadded:: 0.18 Returns ------- diff --git a/sklearn/feature_selection/_rfe.py b/sklearn/feature_selection/_rfe.py index aedcd94943bc4..8dc7aecb7dc3e 100644 --- a/sklearn/feature_selection/_rfe.py +++ b/sklearn/feature_selection/_rfe.py @@ -410,6 +410,8 @@ class RFECV(RFE): ``-1`` means using all processors. See :term:`Glossary ` for more details. + .. versionadded:: 0.18 + Attributes ---------- n_features_ : int diff --git a/sklearn/feature_selection/_univariate_selection.py b/sklearn/feature_selection/_univariate_selection.py index 7e873b3a2b65c..825870293c160 100644 --- a/sklearn/feature_selection/_univariate_selection.py +++ b/sklearn/feature_selection/_univariate_selection.py @@ -384,6 +384,8 @@ class SelectPercentile(_BaseFilter): Default is f_classif (see below "See also"). The default function only works with classification tasks. + ..versionadded:: 0.18 + percentile : int, optional, default=10 Percent of features to keep. @@ -467,6 +469,8 @@ class SelectKBest(_BaseFilter): Default is f_classif (see below "See also"). The default function only works with classification tasks. + ..versionadded:: 0.18 + k : int or "all", optional, default=10 Number of top features to select. The "all" option bypasses selection, for use in a parameter search. diff --git a/sklearn/linear_model/_ransac.py b/sklearn/linear_model/_ransac.py index 5eac651c76383..fffa29d47d91c 100644 --- a/sklearn/linear_model/_ransac.py +++ b/sklearn/linear_model/_ransac.py @@ -150,6 +150,8 @@ class RANSACRegressor(MetaEstimatorMixin, RegressorMixin, If the loss on a sample is greater than the ``residual_threshold``, then this sample is classified as an outlier. + .. versionadded:: 0.18 + random_state : int, RandomState instance, default=None The generator used to initialize the centers. Pass an int for reproducible output across multiple function calls. @@ -239,6 +241,8 @@ def fit(self, X, y, sample_weight=None): raises error if sample_weight is passed and base_estimator fit method does not support it. + .. versionadded:: 0.18 + Raises ------ ValueError diff --git a/sklearn/metrics/_classification.py b/sklearn/metrics/_classification.py index b8a1a8e5e22b4..7bb70c503c946 100644 --- a/sklearn/metrics/_classification.py +++ b/sklearn/metrics/_classification.py @@ -227,6 +227,8 @@ def confusion_matrix(y_true, y_pred, *, labels=None, sample_weight=None, sample_weight : array-like of shape (n_samples,), default=None Sample weights. + .. versionadded:: 0.18 + normalize : {'true', 'pred', 'all'}, default=None Normalizes confusion matrix over the true (rows), predicted (columns) conditions or all the population. If None, confusion matrix will not be @@ -789,6 +791,8 @@ def matthews_corrcoef(y_true, y_pred, *, sample_weight=None): sample_weight : array-like of shape (n_samples,), default=None Sample weights. + .. versionadded:: 0.18 + Returns ------- mcc : float @@ -2038,7 +2042,7 @@ def hamming_loss(y_true, y_pred, *, sample_weight=None): sample_weight : array-like of shape (n_samples,), default=None Sample weights. - .. versionadded:: 0.18 + .. versionadded:: 0.18 Returns ------- @@ -2156,7 +2160,8 @@ def log_loss(y_true, y_pred, *, eps=1e-15, normalize=True, sample_weight=None, If not provided, labels will be inferred from y_true. If ``labels`` is ``None`` and ``y_pred`` has shape (n_samples,) the labels are assumed to be binary and are inferred from ``y_true``. - .. versionadded:: 0.18 + + .. versionadded:: 0.18 Returns ------- diff --git a/sklearn/metrics/cluster/_supervised.py b/sklearn/metrics/cluster/_supervised.py index 8a0fdcacb67f1..d652737bd23c0 100644 --- a/sklearn/metrics/cluster/_supervised.py +++ b/sklearn/metrics/cluster/_supervised.py @@ -881,6 +881,8 @@ def normalized_mutual_info_score(labels_true, labels_pred, *, def fowlkes_mallows_score(labels_true, labels_pred, *, sparse=False): """Measure the similarity of two clusterings of a set of points. + .. versionadded:: 0.18 + The Fowlkes-Mallows index (FMI) is defined as the geometric mean between of the precision and recall:: diff --git a/sklearn/model_selection/_split.py b/sklearn/model_selection/_split.py index edcb9b375ae79..9b2087e039f40 100644 --- a/sklearn/model_selection/_split.py +++ b/sklearn/model_selection/_split.py @@ -739,6 +739,8 @@ def split(self, X, y, groups=None): class TimeSeriesSplit(_BaseKFold): """Time Series cross-validator + .. versionadded:: 0.18 + Provides train/test indices to split time series data samples that are observed at fixed time intervals, in train/test sets. In each split, test indices must be higher than before, and thus shuffling diff --git a/sklearn/multioutput.py b/sklearn/multioutput.py index 815c1cbd67757..a5ede43f0fe8c 100644 --- a/sklearn/multioutput.py +++ b/sklearn/multioutput.py @@ -215,6 +215,8 @@ class MultiOutputRegressor(RegressorMixin, _MultiOutputEstimator): simple strategy for extending regressors that do not natively support multi-target regression. + .. versionadded:: 0.18 + Parameters ---------- estimator : estimator object diff --git a/sklearn/preprocessing/_function_transformer.py b/sklearn/preprocessing/_function_transformer.py index 21dd40365f5a0..36881f4169d64 100644 --- a/sklearn/preprocessing/_function_transformer.py +++ b/sklearn/preprocessing/_function_transformer.py @@ -66,9 +66,13 @@ class FunctionTransformer(TransformerMixin, BaseEstimator): kw_args : dict, optional Dictionary of additional keyword arguments to pass to func. + ..functionadded:: 0.18 + inv_kw_args : dict, optional Dictionary of additional keyword arguments to pass to inverse_func. + ..functionadded:: 0.18 + Examples -------- >>> import numpy as np diff --git a/sklearn/svm/_classes.py b/sklearn/svm/_classes.py index 5ff6e74825e50..d268f1a114d90 100644 --- a/sklearn/svm/_classes.py +++ b/sklearn/svm/_classes.py @@ -213,6 +213,8 @@ def fit(self, X, y, sample_weight=None): samples. If not provided, then each sample is given unit weight. + ..versionadded:: 0.18 + Returns ------- self : object @@ -398,6 +400,8 @@ def fit(self, X, y, sample_weight=None): samples. If not provided, then each sample is given unit weight. + ..versionadded:: 0.18 + Returns ------- self : object From 901ef5375362508619a013d22686c2369f3dc0c0 Mon Sep 17 00:00:00 2001 From: Hannah <32333241+hhnnhh@users.noreply.github.com> Date: Sat, 25 Apr 2020 22:17:50 +0200 Subject: [PATCH 2/3] documentation issues: label changed and added for version 0.18 --- sklearn/cluster/_kmeans.py | 3 ++- sklearn/ensemble/_voting.py | 3 ++- sklearn/feature_selection/_univariate_selection.py | 4 ++-- sklearn/preprocessing/_function_transformer.py | 4 ++-- sklearn/svm/_classes.py | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sklearn/cluster/_kmeans.py b/sklearn/cluster/_kmeans.py index 42c67047cd1c8..7d9545a1f2025 100644 --- a/sklearn/cluster/_kmeans.py +++ b/sklearn/cluster/_kmeans.py @@ -835,7 +835,8 @@ class KMeans(TransformerMixin, ClusterMixin, BaseEstimator): might change in the future for a better heuristic. .. versionchanged:: 0.18 - Added ''algorithm="elkan"'' implementing Elkan's fast K-Means algorithm + Added ''algorithm="elkan"'' implementing Elkan's fast K-Means + algorithm Attributes ---------- diff --git a/sklearn/ensemble/_voting.py b/sklearn/ensemble/_voting.py index 3d49e5f6967c1..0ac42407f5998 100644 --- a/sklearn/ensemble/_voting.py +++ b/sklearn/ensemble/_voting.py @@ -233,7 +233,8 @@ def fit(self, X, y, sample_weight=None): Sample weights. If None, then samples are equally weighted. Note that this is supported only if all underlying estimators support sample weights. - .. versionadded:: 0.18 + + .. versionadded:: 0.18 Returns ------- diff --git a/sklearn/feature_selection/_univariate_selection.py b/sklearn/feature_selection/_univariate_selection.py index 825870293c160..6911830099844 100644 --- a/sklearn/feature_selection/_univariate_selection.py +++ b/sklearn/feature_selection/_univariate_selection.py @@ -384,7 +384,7 @@ class SelectPercentile(_BaseFilter): Default is f_classif (see below "See also"). The default function only works with classification tasks. - ..versionadded:: 0.18 + .. versionadded:: 0.18 percentile : int, optional, default=10 Percent of features to keep. @@ -469,7 +469,7 @@ class SelectKBest(_BaseFilter): Default is f_classif (see below "See also"). The default function only works with classification tasks. - ..versionadded:: 0.18 + .. versionadded:: 0.18 k : int or "all", optional, default=10 Number of top features to select. diff --git a/sklearn/preprocessing/_function_transformer.py b/sklearn/preprocessing/_function_transformer.py index 36881f4169d64..c4e6782b7cb19 100644 --- a/sklearn/preprocessing/_function_transformer.py +++ b/sklearn/preprocessing/_function_transformer.py @@ -66,12 +66,12 @@ class FunctionTransformer(TransformerMixin, BaseEstimator): kw_args : dict, optional Dictionary of additional keyword arguments to pass to func. - ..functionadded:: 0.18 + .. versionadded:: 0.18 inv_kw_args : dict, optional Dictionary of additional keyword arguments to pass to inverse_func. - ..functionadded:: 0.18 + .. versionadded:: 0.18 Examples -------- diff --git a/sklearn/svm/_classes.py b/sklearn/svm/_classes.py index d268f1a114d90..d082c22d0a3bc 100644 --- a/sklearn/svm/_classes.py +++ b/sklearn/svm/_classes.py @@ -213,7 +213,7 @@ def fit(self, X, y, sample_weight=None): samples. If not provided, then each sample is given unit weight. - ..versionadded:: 0.18 + .. versionadded:: 0.18 Returns ------- @@ -400,7 +400,7 @@ def fit(self, X, y, sample_weight=None): samples. If not provided, then each sample is given unit weight. - ..versionadded:: 0.18 + .. versionadded:: 0.18 Returns ------- From eddf4f73bbc94f2baaad28f8b2a7172d0425a3d1 Mon Sep 17 00:00:00 2001 From: "Brigitte@home" Date: Mon, 27 Apr 2020 16:57:16 +0200 Subject: [PATCH 3/3] fix intends and shorten description --- sklearn/cluster/_kmeans.py | 3 +-- sklearn/metrics/_classification.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sklearn/cluster/_kmeans.py b/sklearn/cluster/_kmeans.py index 7d9545a1f2025..8d24ed497aef3 100644 --- a/sklearn/cluster/_kmeans.py +++ b/sklearn/cluster/_kmeans.py @@ -835,8 +835,7 @@ class KMeans(TransformerMixin, ClusterMixin, BaseEstimator): might change in the future for a better heuristic. .. versionchanged:: 0.18 - Added ''algorithm="elkan"'' implementing Elkan's fast K-Means - algorithm + Added Elkan algorithm Attributes ---------- diff --git a/sklearn/metrics/_classification.py b/sklearn/metrics/_classification.py index 7bb70c503c946..2ceccca65203e 100644 --- a/sklearn/metrics/_classification.py +++ b/sklearn/metrics/_classification.py @@ -791,7 +791,7 @@ def matthews_corrcoef(y_true, y_pred, *, sample_weight=None): sample_weight : array-like of shape (n_samples,), default=None Sample weights. - .. versionadded:: 0.18 + .. versionadded:: 0.18 Returns ------- @@ -2042,7 +2042,7 @@ def hamming_loss(y_true, y_pred, *, sample_weight=None): sample_weight : array-like of shape (n_samples,), default=None Sample weights. - .. versionadded:: 0.18 + .. versionadded:: 0.18 Returns ------- @@ -2161,7 +2161,7 @@ def log_loss(y_true, y_pred, *, eps=1e-15, normalize=True, sample_weight=None, is ``None`` and ``y_pred`` has shape (n_samples,) the labels are assumed to be binary and are inferred from ``y_true``. - .. versionadded:: 0.18 + .. versionadded:: 0.18 Returns -------