From 03e0b511e6a6297101bb0371738229c68d894e27 Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 14:16:21 +0000 Subject: [PATCH 01/19] change docstring start to infinitive; change input type to bool --- sklearn/tree/_classes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index c0b1192eafc32..e44240b72ad34 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -446,7 +446,7 @@ def predict(self, X, check_input=True): def apply(self, X, check_input=True): """ - Returns the index of the leaf that each sample is predicted as. + Return the index of the leaf that each sample is predicted as. .. versionadded:: 0.17 @@ -457,7 +457,7 @@ def apply(self, X, check_input=True): ``dtype=np.float32`` and if a sparse matrix is provided to a sparse ``csr_matrix``. - check_input : boolean, (default=True) + check_input : bool, (default=True) Allow to bypass several input checking. Don't use this parameter unless you know what you do. From 326f62b22da291ce7c3c85e3d2a8be302c3c4feb Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 16:04:39 +0000 Subject: [PATCH 02/19] Fix .decision_path docstring. Remove blank line before final """; add period at end of summary; change parameter type to bool --- sklearn/tree/_classes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index e44240b72ad34..e27165ea4f107 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -474,7 +474,7 @@ def apply(self, X, check_input=True): return self.tree_.apply(X) def decision_path(self, X, check_input=True): - """Return the decision path in the tree + """Return the decision path in the tree. .. versionadded:: 0.18 @@ -485,7 +485,7 @@ def decision_path(self, X, check_input=True): ``dtype=np.float32`` and if a sparse matrix is provided to a sparse ``csr_matrix``. - check_input : boolean, (default=True) + check_input : bool, (default=True) Allow to bypass several input checking. Don't use this parameter unless you know what you do. @@ -494,7 +494,6 @@ def decision_path(self, X, check_input=True): indicator : sparse csr array, shape = [n_samples, n_nodes] Return a node indicator matrix where non zero elements indicates that the samples goes through the nodes. - """ X = self._validate_X_predict(X, check_input) return self.tree_.decision_path(X) From ec4d6a7ec2356b26db3bc18f2445f48bfe86a9ac Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 16:35:36 +0000 Subject: [PATCH 03/19] Fix DTC.fit. Change paramter type to bool; add description to return value --- sklearn/tree/_classes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index e27165ea4f107..839a5071546c2 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -852,7 +852,7 @@ def fit(self, X, y, sample_weight=None, check_input=True, ignored if they would result in any single class carrying a negative weight in either child node. - check_input : boolean, (default=True) + check_input : bool, (default=True) Allow to bypass several input checking. Don't use this parameter unless you know what you do. @@ -865,6 +865,7 @@ def fit(self, X, y, sample_weight=None, check_input=True, Returns ------- self : object + Fitted estimator. """ super().fit( From 483e0f1dbb53f1fafbb805e2e4564721ebd6212c Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 16:55:31 +0000 Subject: [PATCH 04/19] Fix docstring for DTC.get_depth: Start summary with infinitive; add Returns --- sklearn/tree/_classes.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 839a5071546c2..438bb3f489bde 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -112,10 +112,15 @@ def __init__(self, self.ccp_alpha = ccp_alpha def get_depth(self): - """Returns the depth of the decision tree. + """Return the depth of the decision tree. The depth of a tree is the maximum distance between the root and any leaf. + + Returns + ------- + self.tree_.max_depth : int or None + The maximum depth of the tree. """ check_is_fitted(self) return self.tree_.max_depth From 6b59695963d2e337c037247deef9fbd5dc2014a5 Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 17:04:59 +0000 Subject: [PATCH 05/19] Fix docstring for DTC.get_n_leaves: Start docstring with infinitve; add Returns section --- sklearn/tree/_classes.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 438bb3f489bde..31d53ed6b77ef 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -126,7 +126,12 @@ def get_depth(self): return self.tree_.max_depth def get_n_leaves(self): - """Returns the number of leaves of the decision tree. + """Return the number of leaves of the decision tree. + + Returns + ------- + self.tree_.n_leaves : int + Number of leaves. """ check_is_fitted(self) return self.tree_.n_leaves From bfd63dbe465d236318b7382b2c28c00060d7b6e5 Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 17:16:14 +0000 Subject: [PATCH 06/19] Fxi docstring DTC .predict: change parameter type to bool --- sklearn/tree/_classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 31d53ed6b77ef..3e30795acf4dc 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -416,7 +416,7 @@ def predict(self, X, check_input=True): ``dtype=np.float32`` and if a sparse matrix is provided to a sparse ``csr_matrix``. - check_input : boolean, (default=True) + check_input : bool, (default=True) Allow to bypass several input checking. Don't use this parameter unless you know what you do. From 9d34c45e6493720b4c133ecc2e0bb39965843c7c Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 17:30:39 +0000 Subject: [PATCH 07/19] Fix docstring for DTC .predict_log_proba: Edit first Returns line to less than 80 chars --- sklearn/tree/_classes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 3e30795acf4dc..9c383eb60b721 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -948,8 +948,7 @@ def predict_log_proba(self, X): Returns ------- - p : array of shape (n_samples, n_classes), or a list of n_outputs - such arrays if n_outputs > 1. + proba : array of shape (n_samples, n_classes), or a list of such arrays The class log-probabilities of the input samples. The order of the classes corresponds to that in the attribute :term:`classes_`. """ From 6cc374461c77cd2ef08131981997c92f3243dd6f Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 17:34:53 +0000 Subject: [PATCH 08/19] Fix docstring for DTC .predict_proba: Correct Returns name and line length --- sklearn/tree/_classes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 9c383eb60b721..e450d6217d3b0 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -907,8 +907,7 @@ class in a leaf. Returns ------- - p : array of shape (n_samples, n_classes), or a list of n_outputs - such arrays if n_outputs > 1. + proba : array of shape (n_samples, n_classes), or a list of such arrays The class probabilities of the input samples. The order of the classes corresponds to that in the attribute :term:`classes_`. """ From 7c30290e0ecbaf9b3095744e5d821ce859ed3f2e Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 17:43:01 +0000 Subject: [PATCH 09/19] Fxi docstring for DTC: correct capitalisation to `See Also` --- sklearn/tree/_classes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index e450d6217d3b0..3cd41a4cf72b2 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -779,7 +779,7 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree): split. To obtain a deterministic behaviour during fitting, ``random_state`` has to be fixed. - See also + See Also -------- DecisionTreeRegressor @@ -1130,7 +1130,7 @@ class DecisionTreeRegressor(RegressorMixin, BaseDecisionTree): split. To obtain a deterministic behaviour during fitting, ``random_state`` has to be fixed. - See also + See Also -------- DecisionTreeClassifier @@ -1424,7 +1424,7 @@ class ExtraTreeClassifier(DecisionTreeClassifier): :ref:`sphx_glr_auto_examples_tree_plot_unveil_tree_structure.py` for basic usage of these attributes. - See also + See Also -------- ExtraTreeRegressor, sklearn.ensemble.ExtraTreesClassifier, sklearn.ensemble.ExtraTreesRegressor @@ -1619,7 +1619,7 @@ class ExtraTreeRegressor(DecisionTreeRegressor): :ref:`sphx_glr_auto_examples_tree_plot_unveil_tree_structure.py` for basic usage of these attributes. - See also + See Also -------- ExtraTreeClassifier, sklearn.ensemble.ExtraTreesClassifier, sklearn.ensemble.ExtraTreesRegressor From 102eb71df26244b903e3df7f4b9fc2bc8e881c49 Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:06:26 +0000 Subject: [PATCH 10/19] fix docstring for DTC: Rremove space after reST `deprecated` --- sklearn/tree/_classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 3cd41a4cf72b2..f64233d17c500 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -722,7 +722,7 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree): presort : deprecated, default='deprecated' This parameter is deprecated and will be removed in v0.24. - .. deprecated :: 0.22 + .. deprecated:: 0.22 ccp_alpha : non-negative float, optional (default=0.0) Complexity parameter used for Minimal Cost-Complexity Pruning. The From 3d7a11d7936bb61ca38d232202dc612ef58dc211 Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:09:12 +0000 Subject: [PATCH 11/19] fix docstring for DTC: Change parameter type to `str` --- sklearn/tree/_classes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index f64233d17c500..90b7826f0808d 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -598,7 +598,7 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree): Parameters ---------- - criterion : string, optional (default="gini") + criterion : str, optional (default="gini") The function to measure the quality of a split. Supported criteria are "gini" for the Gini impurity and "entropy" for the information gain. @@ -970,7 +970,7 @@ class DecisionTreeRegressor(RegressorMixin, BaseDecisionTree): Parameters ---------- - criterion : string, optional (default="mse") + criterion : str, optional (default="mse") The function to measure the quality of a split. Supported criteria are "mse" for the mean squared error, which is equal to variance reduction as feature selection criterion and minimizes the L2 loss @@ -1265,7 +1265,7 @@ class ExtraTreeClassifier(DecisionTreeClassifier): Parameters ---------- - criterion : string, optional (default="gini") + criterion : str, optional (default="gini") The function to measure the quality of a split. Supported criteria are "gini" for the Gini impurity and "entropy" for the information gain. @@ -1489,7 +1489,7 @@ class ExtraTreeRegressor(DecisionTreeRegressor): Parameters ---------- - criterion : string, optional (default="mse") + criterion : str, optional (default="mse") The function to measure the quality of a split. Supported criteria are "mse" for the mean squared error, which is equal to variance reduction as feature selection criterion, and "mae" for the mean From 12d486bd462f4bfb70c87ed1cdaabba15ef0a33f Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:10:35 +0000 Subject: [PATCH 12/19] fix docstring for DTC: Change parameter type to `str` --- sklearn/tree/_classes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 90b7826f0808d..ebfe82c919a84 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -602,7 +602,7 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree): The function to measure the quality of a split. Supported criteria are "gini" for the Gini impurity and "entropy" for the information gain. - splitter : string, optional (default="best") + splitter : str, optional (default="best") The strategy used to choose the split at each node. Supported strategies are "best" to choose the best split and "random" to choose the best random split. @@ -982,7 +982,7 @@ class DecisionTreeRegressor(RegressorMixin, BaseDecisionTree): .. versionadded:: 0.18 Mean Absolute Error (MAE) criterion. - splitter : string, optional (default="best") + splitter : str, optional (default="best") The strategy used to choose the split at each node. Supported strategies are "best" to choose the best split and "random" to choose the best random split. @@ -1269,7 +1269,7 @@ class ExtraTreeClassifier(DecisionTreeClassifier): The function to measure the quality of a split. Supported criteria are "gini" for the Gini impurity and "entropy" for the information gain. - splitter : string, optional (default="random") + splitter : str, optional (default="random") The strategy used to choose the split at each node. Supported strategies are "best" to choose the best split and "random" to choose the best random split. @@ -1498,7 +1498,7 @@ class ExtraTreeRegressor(DecisionTreeRegressor): .. versionadded:: 0.18 Mean Absolute Error (MAE) criterion. - splitter : string, optional (default="random") + splitter : str, optional (default="random") The strategy used to choose the split at each node. Supported strategies are "best" to choose the best split and "random" to choose the best random split. From 12f7fb4a408ec0df0035323c09a783fdb53102d3 Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:20:21 +0000 Subject: [PATCH 13/19] Fix docstring for DTC: Added some missing `See Also` references (not all) --- sklearn/tree/_classes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index ebfe82c919a84..ef3049d8cdc71 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -781,7 +781,7 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree): See Also -------- - DecisionTreeRegressor + DecisionTreeRegressor : A decision tree regressor. References ---------- @@ -1132,7 +1132,7 @@ class DecisionTreeRegressor(RegressorMixin, BaseDecisionTree): See Also -------- - DecisionTreeClassifier + DecisionTreeClassifier : A decision tree classifier. References ---------- From 84f7f54c6d79d92a432a501a203e229dd7f332fc Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:21:52 +0000 Subject: [PATCH 14/19] Fix docstring for DTC: Change parameter type to `str` --- sklearn/tree/_classes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index ef3049d8cdc71..c531e09f63c8a 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -643,7 +643,7 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree): the input samples) required to be at a leaf node. Samples have equal weight when sample_weight is not provided. - max_features : int, float, string or None, optional (default=None) + max_features : int, float, str or None, optional (default=None) The number of features to consider when looking for the best split: - If int, then consider `max_features` features at each split. @@ -1023,7 +1023,7 @@ class DecisionTreeRegressor(RegressorMixin, BaseDecisionTree): the input samples) required to be at a leaf node. Samples have equal weight when sample_weight is not provided. - max_features : int, float, string or None, optional (default=None) + max_features : int, float, str or None, optional (default=None) The number of features to consider when looking for the best split: - If int, then consider `max_features` features at each split. @@ -1310,7 +1310,7 @@ class ExtraTreeClassifier(DecisionTreeClassifier): the input samples) required to be at a leaf node. Samples have equal weight when sample_weight is not provided. - max_features : int, float, string or None, optional (default="auto") + max_features : int, float, str or None, optional (default="auto") The number of features to consider when looking for the best split: - If int, then consider `max_features` features at each split. @@ -1539,7 +1539,7 @@ class ExtraTreeRegressor(DecisionTreeRegressor): the input samples) required to be at a leaf node. Samples have equal weight when sample_weight is not provided. - max_features : int, float, string or None, optional (default="auto") + max_features : int, float, str or None, optional (default="auto") The number of features to consider when looking for the best split: - If int, then consider `max_features` features at each split. From 45eb1571afb39c10f529cc0aeb5f64696048482b Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:27:48 +0000 Subject: [PATCH 15/19] Fix docstrings for DTC: Corrected section order (See Also <-> Notes) --- sklearn/tree/_classes.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index c531e09f63c8a..3f5283d7ae682 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -764,6 +764,10 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree): :ref:`sphx_glr_auto_examples_tree_plot_unveil_tree_structure.py` for basic usage of these attributes. + See Also + -------- + DecisionTreeRegressor : A decision tree regressor. + Notes ----- The default values for the parameters controlling the size of the trees @@ -779,10 +783,6 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree): split. To obtain a deterministic behaviour during fitting, ``random_state`` has to be fixed. - See Also - -------- - DecisionTreeRegressor : A decision tree regressor. - References ---------- @@ -1115,6 +1115,10 @@ class DecisionTreeRegressor(RegressorMixin, BaseDecisionTree): :ref:`sphx_glr_auto_examples_tree_plot_unveil_tree_structure.py` for basic usage of these attributes. + See Also + -------- + DecisionTreeClassifier : A decision tree classifier. + Notes ----- The default values for the parameters controlling the size of the trees @@ -1130,10 +1134,6 @@ class DecisionTreeRegressor(RegressorMixin, BaseDecisionTree): split. To obtain a deterministic behaviour during fitting, ``random_state`` has to be fixed. - See Also - -------- - DecisionTreeClassifier : A decision tree classifier. - References ---------- From 3b251c6bef5e14efb58e04314f0a2d9fcce5dfbb Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:41:41 +0000 Subject: [PATCH 16/19] Fix docstring for DTR: remove space between reST `deprecated` and `::` --- sklearn/tree/_classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 3f5283d7ae682..67aae7b36bec6 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -1081,7 +1081,7 @@ class DecisionTreeRegressor(RegressorMixin, BaseDecisionTree): presort : deprecated, default='deprecated' This parameter is deprecated and will be removed in v0.24. - .. deprecated :: 0.22 + .. deprecated:: 0.22 ccp_alpha : non-negative float, optional (default=0.0) Complexity parameter used for Minimal Cost-Complexity Pruning. The From 1689678ba19e55833d49c0a0f668b9ee8fc4180b Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:59:14 +0000 Subject: [PATCH 17/19] Fix docstring for DTR .fit: Set parameter type to `bool`; Add Returns descriptions --- sklearn/tree/_classes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index 67aae7b36bec6..c354b268e3575 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -581,6 +581,7 @@ def feature_importances_(self): Returns ------- feature_importances_ : array, shape = [n_features] + Normalized total reduction of critera by feature (Gini importance). """ check_is_fitted(self) @@ -1210,7 +1211,7 @@ def fit(self, X, y, sample_weight=None, check_input=True, that would create child nodes with net zero or negative weight are ignored while searching for a split in each node. - check_input : boolean, (default=True) + check_input : bool, (default=True) Allow to bypass several input checking. Don't use this parameter unless you know what you do. @@ -1223,6 +1224,7 @@ def fit(self, X, y, sample_weight=None, check_input=True, Returns ------- self : object + Fitted estimator. """ super().fit( From bb1cd942e5440bd41e662bc6294a3a0eca4e9371 Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Sat, 2 Nov 2019 19:13:38 +0000 Subject: [PATCH 18/19] Fix docstring for DTR .score: Start docstring summaries with `Return` not `Returns` --- sklearn/base.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sklearn/base.py b/sklearn/base.py index 2ec022c2d6da1..efa9633333329 100644 --- a/sklearn/base.py +++ b/sklearn/base.py @@ -369,7 +369,7 @@ class RegressorMixin: _estimator_type = "regressor" def score(self, X, y, sample_weight=None): - """Returns the coefficient of determination R^2 of the prediction. + """Return the coefficient of determination R^2 of the prediction. The coefficient R^2 is defined as (1 - u/v), where u is the residual sum of squares ((y_true - y_pred) ** 2).sum() and v is the total @@ -506,7 +506,7 @@ def get_shape(self, i): return tuple(len(i) for i in indices) def get_submatrix(self, i, data): - """Returns the submatrix corresponding to bicluster `i`. + """Return the submatrix corresponding to bicluster `i`. Parameters ---------- @@ -569,7 +569,7 @@ class DensityMixin: _estimator_type = "DensityEstimator" def score(self, X, y=None): - """Returns the score of the model on the data X + """Return the score of the model on the data X Parameters ---------- @@ -627,7 +627,7 @@ def _more_tags(self): def is_classifier(estimator): - """Returns True if the given estimator is (probably) a classifier. + """Return True if the given estimator is (probably) a classifier. Parameters ---------- @@ -643,7 +643,7 @@ def is_classifier(estimator): def is_regressor(estimator): - """Returns True if the given estimator is (probably) a regressor. + """Return True if the given estimator is (probably) a regressor. Parameters ---------- @@ -659,7 +659,7 @@ def is_regressor(estimator): def is_outlier_detector(estimator): - """Returns True if the given estimator is (probably) an outlier detector. + """Return True if the given estimator is (probably) an outlier detector. Parameters ---------- From 7ee8125d227be26d7837ad35ea39286517ab91fc Mon Sep 17 00:00:00 2001 From: RichardP <42078073+r-build@users.noreply.github.com> Date: Mon, 4 Nov 2019 18:59:20 +0000 Subject: [PATCH 19/19] Fix docstrings for DTC: restore text; remove None return type for get_depth --- sklearn/tree/_classes.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sklearn/tree/_classes.py b/sklearn/tree/_classes.py index e2b5966c1cab0..c103154119e32 100644 --- a/sklearn/tree/_classes.py +++ b/sklearn/tree/_classes.py @@ -119,7 +119,7 @@ def get_depth(self): Returns ------- - self.tree_.max_depth : int or None + self.tree_.max_depth : int The maximum depth of the tree. """ check_is_fitted(self) @@ -908,7 +908,8 @@ class in a leaf. Returns ------- - proba : array of shape (n_samples, n_classes), or a list of such arrays + proba : array of shape (n_samples, n_classes), or a list of n_outputs \ + such arrays if n_outputs > 1. The class probabilities of the input samples. The order of the classes corresponds to that in the attribute :term:`classes_`. """ @@ -948,7 +949,8 @@ def predict_log_proba(self, X): Returns ------- - proba : array of shape (n_samples, n_classes), or a list of such arrays + proba : array of shape (n_samples, n_classes), or a list of n_outputs \ + such arrays if n_outputs > 1. The class log-probabilities of the input samples. The order of the classes corresponds to that in the attribute :term:`classes_`. """