8000 DOC fix docstring in ensemble module (#18228) · alexshacked/scikit-learn@a675319 · GitHub
[go: up one dir, main page]

Skip to content

Commit a675319

Browse files
authored
DOC fix docstring in ensemble module (scikit-learn#18228)
1 parent 66c99e3 commit a675319

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

sklearn/ensemble/_bagging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ class BaggingClassifier(ClassifierMixin, BaseBagging):
503503
:obj:`joblib.parallel_backend` context. ``-1`` means using all
504504
processors. See :term:`Glossary <n_jobs>` for more details.
505505
506-
random_state : int or RandomState, default=None
506+
random_state : int, RandomState instance or None, default=None
507507
Controls the random resampling of the original dataset
508508
(sample wise and feature wise).
509509
If the base estimator accepts a `random_state` attribute, a different
@@ -909,7 +909,7 @@ class BaggingRegressor(RegressorMixin, BaseBagging):
909909
:obj:`joblib.parallel_backend` context. ``-1`` means using all
910910
processors. See :term:`Glossary <n_jobs>` for more details.
911911
912-
random_state : int or RandomState, default=None
912+
random_state : int, RandomState instance or None, default=None
913913
Controls the random resampling of the original dataset
914914
(sample wise and feature wise).
915915
If the base estimator accepts a `random_state` attribute, a different

sklearn/ensemble/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _set_random_states(estimator, random_state=None):
5252
Estimator with potential randomness managed by random_state
5353
parameters.
5454
55-
random_state : int or RandomState, default=None
55+
random_state : int, RandomState instance or None, default=None
5656
Pseudo-random number generator to control the generation of the random
5757
integers. Pass an int for reproducible output across multiple function
5858
calls.

sklearn/ensemble/_forest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ class RandomForestClassifier(ForestClassifier):
10081008
context. ``-1`` means using all processors. See :term:`Glossary
10091009
<n_jobs>` for more details.
10101010
1011-
random_state : int or RandomState, default=None
1011+
random_state : int, RandomState instance or None, default=None
10121012
Controls both the randomness of the bootstrapping of the samples used
10131013
when building trees (if ``bootstrap=True``) and the sampling of the
10141014
features to consider when looking for the best split at each node
@@ -1330,7 +1330,7 @@ class RandomForestRegressor(ForestRegressor):
13301330
context. ``-1`` means using all processors. See :term:`Glossary
13311331
<n_jobs>` for more details.
13321332
1333-
random_state : int or RandomState, default=None
1333+
random_state : int, RandomState instance or None, default=None
13341334
Controls both the randomness of the bootstrapping of the samples used
13351335
when building trees (if ``bootstrap=True``) and the sampling of the
13361336
features to consider when looking for the best split at each node
@@ -1612,7 +1612,7 @@ class ExtraTreesClassifier(ForestClassifier):
16121612
context. ``-1`` means using all processors. See :term:`Glossary
16131613
<n_jobs>` for more details.
16141614
1615-
random_state : int, RandomState, default=None
1615+
random_state : int, RandomState instance or None, default=None
16161616
Controls 3 sources of randomness:
16171617
16181618
- the bootstrapping of the samples used when building trees
@@ -1929,7 +1929,7 @@ class ExtraTreesRegressor(ForestRegressor):
19291929
context. ``-1`` means using all processors. See :term:`Glossary
19301930
<n_jobs>` for more details.
19311931
1932-
random_state : int or RandomState, default=None
1932+
random_state : int, RandomState instance or None, default=None
19331933
Controls 3 sources of randomness:
19341934
19351935
- the bootstrapping of the samples used when building trees
@@ -2185,7 +2185,7 @@ class RandomTreesEmbedding(BaseForest):
21852185
context. ``-1`` means using all processors. See :term:`Glossary
21862186
<n_jobs>` for more details.
21872187
2188-
random_state : int or RandomState, default=None
2188+
random_state : int, RandomState instance or None, default=None
21892189
Controls the generation of the random `y` used to fit the trees
21902190
and the draw of the splits for each feature at the trees' nodes.
21912191
See :term:`Glossary <random_state>` for details.

sklearn/ensemble/_gb.py

Lines changed: 12 additions & 12 deletions
6D4E
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Gradient Boosted Regression Trees
1+
"""Gradient Boosted Regression Trees.
22
33
This module contains methods for fitting gradient boosted regression trees for
44
both classification and regression.
@@ -107,9 +107,9 @@ def update(self, j, est):
107107
Parameters
108108
----------
109109
j : int
110-
The new iteration
110+
The new iteration.
111111
est : Estimator
112-
The estimator
112+
The estimator.
113113
"""
114114
do_oob = est.subsample < 1
115115
# we need to take into account if we fit additional estimators.
@@ -132,7 +132,7 @@ def update(self, j, est):
132132

133133

134134
class BaseGradientBoosting(BaseEnsemble, metaclass=ABCMeta):
135-
"""Abstract base class for Gradient Boosting. """
135+
"""Abstract base class for Gradient Boosting."""
136136

137137
@abstractmethod
138138
def __init__(self, *, loss, learning_rate, n_estimators, criterion,
@@ -168,11 +168,11 @@ def __init__(self, *, loss, learning_rate, n_estimators, criterion,
168168

169169
@abstractmethod
170170
def _validate_y(self, y, sample_weight=None):
171-
"""Called by fit to validate y"""
171+
"""Called by fit to validate y."""
172172

173173
def _fit_stage(self, i, X, y, raw_predictions, sample_weight, sample_mask,
174174
random_state, X_csc=None, X_csr=None):
175-
"""Fit another stage of ``_n_classes`` trees to the boosting model. """
175+
"""Fit another stage of ``_n_classes`` trees to the boosting model."""
176176

177177
assert sample_mask.dtype == bool
178178
loss = self.loss_
@@ -225,7 +225,7 @@ def _fit_stage(self, i, X, y, raw_predictions, sample_weight, sample_mask,
225225
return raw_predictions
226226

227227
def _check_params(self):
228-
"""Check validity of parameters and raise ValueError if not valid. """
228+
"""Check validity of parameters and raise ValueError if not valid."""
229229
if self.n_estimators <= 0:
230230
raise ValueError("n_estimators must be greater than 0 but "
231231
"was %r" % self.n_estimators)
@@ -332,7 +332,7 @@ def _clear_state(self):
332332
del self._rng
333333

334334
def _resize_state(self):
335-
"""Add additional ``n_estimators`` entries to all attributes. """
335+
"""Add additional ``n_estimators`` entries to all attributes."""
336336
# self.n_estimators is the number of additional est to fit
337337
total_n_estimators = self.n_estimators
338338
if total_n_estimators < self.estimators_.shape[0]:
@@ -660,7 +660,7 @@ def feature_importances_(self):
660660
661661
Returns
662662
-------
663-
feature_importances_ : array, shape (n_features,)
663+
feature_importances_ : ndarray of shape (n_features,)
664664
The values of this array sum to 1, unless all trees are single node
665665
trees consisting of only the root node, in which case it will be an
666666
array of zeros.
@@ -873,7 +873,7 @@ class GradientBoostingClassifier(ClassifierMixin, BaseGradientBoosting):
873873
'zero', the initial raw predictions are set to zero. By default, a
874874
``DummyEstimator`` predicting the classes priors is used.
875875
876-
random_state : int or RandomState, default=None
876+
random_state : int, RandomState instance or None, default=None
877877
Controls the random seed given to each Tree estimator at each
878878
boosting iteration.
879879
In addition, it controls the random permutation of the features at
@@ -1118,7 +1118,7 @@ def decision_function(self, X):
11181118
the raw values predicted from the trees of the ensemble . The
11191119
order of the classes corresponds to that in the attribute
11201120
:term:`classes_`. Regression and binary classification produce an
1121-
array of shape [n_samples].
1121+
array of shape (n_samples,).
11221122
"""
11231123
X = check_array(X, dtype=DTYPE, order="C", accept_sparse='csr')
11241124
raw_predictions = self._raw_predict(X)
@@ -1392,7 +1392,7 @@ class GradientBoostingRegressor(RegressorMixin, BaseGradientBoosting):
13921392
``DummyEstimator`` is used, predicting either the average target value
13931393
(for loss='ls'), or a quantile for the other losses.
13941394
1395-
random_state : int or RandomState, default=None
1395+
random_state : int, RandomState instance or None, default=None
13961396
Controls the random seed given to each Tree estimator at each
13971397
boosting iteration.
13981398
In addition, it controls the random permutation of the features at

sklearn/ensemble/_iforest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class IsolationForest(OutlierMixin, BaseBagging):
9393
:obj:`joblib.parallel_backend` context. ``-1`` means using all
9494
processors. See :term:`Glossary <n_jobs>` for more details.
9595
96-
random_state : int or RandomState, default=None
96+
random_state : int, RandomState instance or None, default=None
9797
Controls the pseudo-randomness of the selection of the feature
9898
and split values for each branching step and each tree in the forest.
9999

sklearn/ensemble/_weight_boosting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Weight Boosting
1+
"""Weight Boosting.
22
33
This module contains weight boosting estimators for both classification and
44
regression.
@@ -322,7 +322,7 @@ class AdaBoostClassifier(ClassifierMixin, BaseWeightBoosting):
322322
The SAMME.R algorithm typically converges faster than SAMME,
323323
achieving a lower test error with fewer boosting iterations.
324324
325-
random_state : int or RandomState, default=None
325+
random_state : int, RandomState instance or None, default=None
326326
Controls the random seed given at each `base_estimator` at each
327327
boosting iteration.
328328
Thus, it is only used when `base_estimator` exposes a `random_state`.
@@ -482,7 +482,7 @@ def _boost(self, iboost, X, y, sample_weight, random_state):
482482
sample_weight : array-like of shape (n_samples,)
483483
The current sample weights.
484484
485-
random_state : RandomState
485+
random_state : RandomState instance
486486
The RandomState instance used if the base estimator accepts a
487487
`random_state` attribute.
488488
@@ -905,7 +905,7 @@ class AdaBoostRegressor(RegressorMixin, BaseWeightBoosting):
905905
The loss function to use when updating the weights after each
906906
boosting iteration.
907907
908-
random_state : int or RandomState, default=None
908+
random_state : int, RandomState instance or None, default=None
909909
Controls the random seed given at each `base_estimator` at each
910910
boosting iteration.
911911
Thus, it is only used when `base_estimator` exposes a `random_state`.

0 commit comments

Comments
 (0)
0