10000 DOC Ensures that BaggingClassifier passes numpydoc validation #20377 … · scikit-learn/scikit-learn@04edd21 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04edd21

Browse files
jbsilvaogrisel
andauthored
DOC Ensures that BaggingClassifier passes numpydoc validation #20377 (#20407)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
1 parent 1eece2c commit 04edd21

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"AdditiveChi2Sampler",
1313
"AffinityPropagation",
1414
"AgglomerativeClustering",
15-
"BaggingClassifier",
1615
"BaggingRegressor",
1716
"BernoulliNB",
1817
"BernoulliRBM",

sklearn/ensemble/_bagging.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ def __init__(
235235
self.verbose = verbose
236236

237237
def fit(self, X, y, sample_weight=None):
238-
"""Build a Bagging ensemble of estimators from the training
239-
set (X, y).
238+
"""Build a Bagging ensemble of estimators from the training set (X, y).
240239
241240
Parameters
242241
----------
@@ -256,6 +255,7 @@ def fit(self, X, y, sample_weight=None):
256255
Returns
257256
-------
258257
self : object
258+
Fitted estimator.
259259
"""
260260
return self._fit(X, y, self.max_samples, sample_weight=sample_weight)< 8000 /div>
261261

@@ -291,6 +291,7 @@ def _fit(self, X, y, max_samples=None, max_depth=None, sample_weight=None):
291291
Returns
292292
-------
293293
self : object
294+
Fitted estimator.
294295
"""
295296
random_state = check_random_state(self.random_state)
296297

@@ -601,18 +602,9 @@ class BaggingClassifier(ClassifierMixin, BaseBagging):
601602
`oob_decision_function_` might contain NaN. This attribute exists
602603
only when ``oob_score`` is True.
603604
604-
Examples
605+
See Also
605606
--------
606-
>>> from sklearn.svm import SVC
607-
>>> from sklearn.ensemble import BaggingClassifier
608-
>>> from sklearn.datasets import make_classification
609-
>>> X, y = make_classification(n_samples=100, n_features=4,
610-
... n_informative=2, n_redundant=0,
611< 8000 span class="diff-text-marker">-
... random_state=0, shuffle=False)
612-
>>> clf = BaggingClassifier(base_estimator=SVC(),
613-
... n_estimators=10, random_state=0).fit(X, y)
614-
>>> clf.predict([[0, 0, 0, 0]])
615-
array([1])
607+
BaggingRegressor : A Bagging regressor.
616608
617609
References
618610
----------
@@ -629,6 +621,19 @@ class BaggingClassifier(ClassifierMixin, BaseBagging):
629621
630622
.. [4] G. Louppe and P. Geurts, "Ensembles on Random Patches", Machine
631623
Learning and Knowledge Discovery in Databases, 346-361, 2012.
624+
625+
Examples
626+
--------
627+
>>> from sklearn.svm import SVC
628+
>>> from sklearn.ensemble import BaggingClassifier
629+
>>> from sklearn.datasets import make_classification
630+
>>> X, y = make_classification(n_samples=100, n_features=4,
631+
... n_informative=2, n_redundant=0,
632+
... random_state=0, shuffle=False)
633+
>>> clf = BaggingClassifier(base_estimator=SVC(),
634+
... n_estimators=10, random_state=0).fit(X, y)
635+
>>> clf.predict([[0, 0, 0, 0]])
636+
array([1])
632637
"""
633638

634639
def __init__(
@@ -862,7 +867,6 @@ def decision_function(self, X):
862867
to the classes in sorted order, as they appear in the attribute
863868
``classes_``. Regression and binary classification are special
864869
cases with ``k == 1``, otherwise ``k==n_classes``.
865-
866870
"""
867871
check_is_fitted(self)
868872

0 commit comments

Comments
 (0)
0