@@ -546,14 +546,11 @@ class BaggingClassifier(ClassifierMixin, BaseBagging):
546
546
>>> from sklearn.svm import SVC
547
547
>>> from sklearn.ensemble import BaggingClassifier
548
548
>>> from sklearn.datasets import make_classification
549
- >>> X, y = make_classification(n_samples=1000 , n_features=4,
549
+ >>> X, y = make_classification(n_samples=100 , n_features=4,
550
550
... n_informative=2, n_redundant=0,
551
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
552
>>> clf = BaggingClassifier(base_estimator=SVC(),
556
- ... n_estimators=100 , random_state=0).fit(X, y)
553
+ ... n_estimators=10 , random_state=0).fit(X, y)
557
554
>>> clf.predict([[0, 0, 0, 0]])
558
555
array([1])
559
556
@@ -935,6 +932,19 @@ class BaggingRegressor(RegressorMixin, BaseBagging):
935
932
`oob_prediction_` might contain NaN. This attribute exists only
936
933
when ``oob_score`` is True.
937
934
935
+ Examples
936
+ --------
937
+ >>> from sklearn.svm import SVR
938
+ >>> from sklearn.ensemble import BaggingRegressor
939
+ >>> from sklearn.datasets import make_regression
940
+ >>> X, y = make_regression(n_samples=100, n_features=4,
941
+ ... n_informative=2, n_targets=1,
942
+ ... random_state=0, shuffle=False)
943
+ >>> regr = BaggingRegressor(base_estimator=SVR(),
944
+ ... n_estimators=10, random_state=0).fit(X, y)
945
+ >>> regr.predict([[0, 0, 0, 0]])
946
+ array([-2.8720...])
947
+
938
948
References
939
949
----------
940
950
0 commit comments