From 77dc6fe0dba92aaaeb666875bd9b2ef8a0375bf8 Mon Sep 17 00:00:00 2001 From: Alina Cucu Date: Sat, 25 Jan 2020 14:02:49 +0100 Subject: [PATCH] added versionadded 0.21 and versionchanged 0.21 where applicable, after inspecting changelog --- .gitignore | 1 + sklearn/cluster/_agglomerative.py | 2 ++ sklearn/cluster/_optics.py | 4 ++++ sklearn/compose/_column_transformer.py | 4 ++++ sklearn/externals/_scipy_linalg.py | 2 ++ sklearn/pipeline.py | 11 +++++++++++ .../preprocessing/_csr_polynomial_expansion.pyx | 2 ++ sklearn/preprocessing/_data.py | 2 ++ sklearn/preprocessing/_encoders.py | 4 ++++ sklearn/preprocessing/_label.py | 2 ++ sklearn/tree/_classes.py | 4 ++++ sklearn/tree/_export.py | 2 ++ sklearn/utils/__init__.py | 2 ++ sklearn/utils/estimator_checks.py | 17 +++++++++++------ sklearn/utils/fixes.py | 3 +++ 15 files changed, 56 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9b158da07a2ec..80a8c855010e4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.lprof *.swp *.swo +env/ .DS_Store build sklearn/datasets/__config__.py diff --git a/sklearn/cluster/_agglomerative.py b/sklearn/cluster/_agglomerative.py index c64b9b03f8d84..e314af84dd46e 100644 --- a/sklearn/cluster/_agglomerative.py +++ b/sklearn/cluster/_agglomerative.py @@ -755,6 +755,8 @@ class AgglomerativeClustering(ClusterMixin, BaseEstimator): n_connected_components_ : int The estimated number of connected components in the graph. + .. versionchanged:: 0.21 + children_ : array-like of shape (n_samples-1, 2) The children of each non-leaf node. Values less than `n_samples` correspond to leaves of the tree which are the original samples. diff --git a/sklearn/cluster/_optics.py b/sklearn/cluster/_optics.py index ec2c45453d2be..4354089465be5 100755 --- a/sklearn/cluster/_optics.py +++ b/sklearn/cluster/_optics.py @@ -51,6 +51,8 @@ class OPTICS(ClusterMixin, BaseEstimator): number or a fraction of the number of samples (rounded to be at least 2). + .. versionadded:: 0.21 + max_eps : float, optional (default=np.inf) The maximum distance between two samples for one to be considered as in the neighborhood of the other. Default value of ``np.inf`` will @@ -119,6 +121,8 @@ class OPTICS(ClusterMixin, BaseEstimator): at least 2). If ``None``, the value of ``min_samples`` is used instead. Used only when ``cluster_method='xi'``. + .. versionadded:: 0.21 + algorithm : {'auto', 'ball_tree', 'kd_tree', 'brute'}, optional Algorithm used to compute the nearest neighbors: diff --git a/sklearn/compose/_column_transformer.py b/sklearn/compose/_column_transformer.py index 0b6a7363686a9..c83292f305cbe 100644 --- a/sklearn/compose/_column_transformer.py +++ b/sklearn/compose/_column_transformer.py @@ -110,6 +110,8 @@ class ColumnTransformer(TransformerMixin, _BaseComposition): If True, the time elapsed while fitting each transformer will be printed as it is completed. + .. versionadded:: 0.21 + Attributes ---------- transformers_ : list @@ -717,6 +719,8 @@ def make_column_transformer(*transformers, **kwargs): If True, the time elapsed while fitting each transformer will be printed as it is completed. + .. versionadded:: 0.21 + Returns ------- ct : ColumnTransformer diff --git a/sklearn/externals/_scipy_linalg.py b/sklearn/externals/_scipy_linalg.py index 70a6ff5a0c623..0a90f076ad0c7 100644 --- a/sklearn/externals/_scipy_linalg.py +++ b/sklearn/externals/_scipy_linalg.py @@ -51,6 +51,8 @@ def pinvh(a, cond=None, rcond=None, lower=True, return_rank=False, using its eigenvalue decomposition and including all eigenvalues with 'large' absolute value. + .. versionadded:: 0.21 + Parameters ---------- a : (N, N) array_like diff --git a/sklearn/pipeline.py b/sklearn/pipeline.py index af2feed1a861e..6e25493f89671 100644 --- a/sklearn/pipeline.py +++ b/sklearn/pipeline.py @@ -70,6 +70,8 @@ class Pipeline(_BaseComposition): If True, the time elapsed while fitting each step will be printed as it is completed. + .. versionadded:: 0.21 + Attributes ---------- named_steps : bunch object, a dictionary with attribute access @@ -211,6 +213,9 @@ def _iter(self, with_final=True, filter_passthrough=True): def __len__(self): """ Returns the length of the Pipeline + + .. versionadded:: 0.21 + """ return len(self.steps) @@ -678,6 +683,8 @@ def make_pipeline(*steps, **kwargs): If True, the time elapsed while fitting each step will be printed as it is completed. + .. versionadded:: 0.21 + See Also -------- sklearn.pipeline.Pipeline : Class for creating a pipeline of @@ -787,6 +794,8 @@ class FeatureUnion(TransformerMixin, _BaseComposition): If True, the time elapsed while fitting each transformer will be printed as it is completed. + .. versionadded:: 0.21 + See Also -------- sklearn.pipeline.make_union : Convenience function for simplified @@ -1020,6 +1029,8 @@ def make_union(*transformers, **kwargs): If True, the time elapsed while fitting each transformer will be printed as it is completed. + .. versionadded:: 0.21 + Returns ------- f : FeatureUnion diff --git a/sklearn/preprocessing/_csr_polynomial_expansion.pyx b/sklearn/preprocessing/_csr_polynomial_expansion.pyx index dd36f8321410f..64bf6d2d04f3c 100644 --- a/sklearn/preprocessing/_csr_polynomial_expansion.pyx +++ b/sklearn/preprocessing/_csr_polynomial_expansion.pyx @@ -83,6 +83,8 @@ def _csr_polynomial_expansion(ndarray[DATA_T, ndim=1] data, ---------- "Leveraging Sparsity to Speed Up Polynomial Feature Expansions of CSR Matrices Using K-Simplex Numbers" by Andrew Nystrom and John Hughes. + + .. versionadded:: 0.21 """ assert degree in (2, 3) diff --git a/sklearn/preprocessing/_data.py b/sklearn/preprocessing/_data.py index b047908842b38..dbf207b698f4f 100644 --- a/sklearn/preprocessing/_data.py +++ b/sklearn/preprocessing/_data.py @@ -2161,6 +2161,8 @@ class QuantileTransformer(TransformerMixin, BaseEstimator): a better approximation of the cumulative distribution function estimator. + .. versionchanged:: 0.21 + output_distribution : str, optional (default='uniform') Marginal distribution for the transformed data. The choices are 'uniform' (default) or 'normal'. diff --git a/sklearn/preprocessing/_encoders.py b/sklearn/preprocessing/_encoders.py index 36512e359c7ed..11a79e86fa39d 100644 --- a/sklearn/preprocessing/_encoders.py +++ b/sklearn/preprocessing/_encoders.py @@ -37,6 +37,8 @@ def _check_X(self, X): of pandas DataFrame columns, as otherwise information is lost and cannot be used, eg for the `categories_` attribute. + .. versionchanged:: 0.21 + """ if not (hasattr(X, 'iloc') and getattr(X, 'ndim', 0) == 2): # if not a dataframe, do normal check_array validation @@ -198,6 +200,8 @@ class OneHotEncoder(_BaseEncoder): - array : ``drop[i]`` is the category in feature ``X[:, i]`` that should be dropped. + .. versionadded:: 0.21 + sparse : bool, default=True Will return sparse matrix if set True else will return an array. diff --git a/sklearn/preprocessing/_label.py b/sklearn/preprocessing/_label.py index c644aa919f5cf..b35347cebfb47 100644 --- a/sklearn/preprocessing/_label.py +++ b/sklearn/preprocessing/_label.py @@ -950,6 +950,8 @@ def transform(self, y): return yt def _build_cache(self): + """ .. versionadded:: 0.21""" + if self._cached_dict is None: self._cached_dict = dict(zip(self.classes_, range(len(self.classes_)))) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index eade7c9e56ad5..be4ca7ed9df84 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -118,6 +118,8 @@ def get_depth(self): The depth of a tree is the maximum distance between the root and any leaf. + .. versionadded:: 0.21 + Returns ------- self.tree_.max_depth : int @@ -129,6 +131,8 @@ def get_depth(self): def get_n_leaves(self): """Return the number of leaves of the decision tree. + .. versionadded:: 0.21 + Returns ------- self.tree_.n_leaves : int diff --git a/sklearn/tree/_export.py b/sklearn/tree/_export.py index 212ae4e309749..490f9dab26b2f 100644 --- a/sklearn/tree/_export.py +++ b/sklearn/tree/_export.py @@ -809,6 +809,8 @@ def export_text(decision_tree, feature_names=None, max_depth=10, Note that backwards compatibility may not be supported. + .. versionadded:: 0.21 + Parameters ---------- decision_tree : object diff --git a/sklearn/utils/__init__.py b/sklearn/utils/__init__.py index ee38b9b924ccc..85e78643a056f 100644 --- a/sklearn/utils/__init__.py +++ b/sklearn/utils/__init__.py @@ -486,6 +486,8 @@ def resample(*arrays, **options): If not None, data is split in a stratified fashion, using this as the class labels. + .. versionadded:: 0.21 + Returns ------- resampled_arrays : sequence of indexable data-structures diff --git a/sklearn/utils/estimator_checks.py b/sklearn/utils/estimator_checks.py index b8471daf5deab..925cd77703359 100644 --- a/sklearn/utils/estimator_checks.py +++ b/sklearn/utils/estimator_checks.py @@ -2787,12 +2787,17 @@ def check_fit_non_negative(name, estimator_orig): def check_fit_idempotent(name, estimator_orig): - # Check that est.fit(X) is the same as est.fit(X).fit(X). Ideally we would - # check that the estimated parameters during training (e.g. coefs_) are - # the same, but having a universal comparison function for those - # attributes is difficult and full of edge cases. So instead we check that - # predict(), predict_proba(), decision_function() and transform() return - # the same results. + """ + Check that est.fit(X) is the same as est.fit(X).fit(X). Ideally we would + check that the estimated parameters during training (e.g. coefs_) are + the same, but having a universal comparison function for those + attributes is difficult and full of edge cases. So instead we check that + predict(), predict_proba(), decision_function() and transform() return + the same results. + + .. versionadded:: 0.21 + + """ check_methods = ["predict", "transform", "decision_function", "predict_proba"] diff --git a/sklearn/utils/fixes.py b/sklearn/utils/fixes.py index 4456e9d271329..b2285ed0b1935 100644 --- a/sklearn/utils/fixes.py +++ b/sklearn/utils/fixes.py @@ -190,6 +190,9 @@ def _astype_copy_false(X): """Returns the copy=False parameter for {ndarray, csr_matrix, csc_matrix}.astype when possible, otherwise don't specify + + .. versionadded:: 0.21 + """ if sp_version >= (1, 1) or not sp.issparse(X): return {'copy': False}