8000 DOC add BaggingClassifier Examples (#14923) · crankycoder/scikit-learn@c6b5eb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6b5eb2

Browse files
JesperDramschrth
authored andcommitted
DOC add BaggingClassifier Examples (scikit-learn#14923)
1 parent f450173 commit c6b5eb2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sklearn/ensemble/bagging.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,22 @@ class BaggingClassifier(ClassifierMixin, BaseBagging):
541541
`oob_decision_function_` might contain NaN. This attribute exists
542542
only when ``oob_score`` is True.
543543
544+
Examples
545+
--------
546+
>>> from sklearn.svm import SVC
547+
>>> from sklearn.ensemble import BaggingClassifier
548+
>>> from sklearn.datasets import make_classification
549+
>>> X, y = make_classification(n_samples=1000, n_features=4,
550+
... n_informative=2, n_redundant=0,
551+
... random_state=0, shuffle=False)
552+
>>> clf = BaggingClassifier(n_estimators=100, random_state=0).fit(X, y)
553+
>>> clf.predict([[0, 0, 0, 0]])
554+
array([1])
555+
>>> clf = BaggingClassifier(base_estimator=SVC(),
556+
... n_estimators=100, random_state=0).fit(X, y)
557+
>>> clf.predict([[0, 0, 0, 0]])
558+
array([1])
559+
544560
References
545561
----------
546562

0 commit comments

Comments
 (0)
0