10000 DOC Ensures that BaggingClassifier passes numpydoc validation #20377 by jbsilva · Pull Request #20407 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Ensures that BaggingClassifier passes numpydoc validation #20377 #20407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"AdditiveChi2Sampler",
"AffinityPropagation",
"AgglomerativeClustering",
"BaggingClassifier",
"BaggingRegressor",
"BernoulliNB",
"BernoulliRBM",
Expand Down
32 changes: 18 additions & 14 deletions sklearn/ensemble/_bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ def __init__(
self.verbose = verbose

def fit(self, X, y, sample_weight=None):
"""Build a Bagging ensemble of estimators from the training
set (X, y).
"""Build a Bagging ensemble of estimators from the training set (X, y).

Parameters
----------
Expand All @@ -256,6 +255,7 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Fitted estimator.
"""
return self._fit(X, y, self.max_samples, sample_weight=sample_weight)

Expand Down Expand Up @@ -291,6 +291,7 @@ def _fit(self, X, y, max_samples=None, max_depth=None, sample_weight=None):
Returns
-------
self : object
Fitted estimator.
"""
random_state = check_random_state(self.random_state)

Expand Down Expand Up @@ -605,18 +606,9 @@ class BaggingClassifier(ClassifierMixin, BaseBagging):
`oob_decision_function_` might contain NaN. This attribute exists
only when ``oob_score`` is True.

Examples
See Also
--------
>>> from sklearn.svm import SVC
>>> from sklearn.ensemble import BaggingClassifier
>>> from sklearn.datasets import make_classification
>>> X, y = make_classification(n_samples=100, n_features=4,
... n_informative=2, n_redundant=0,
... random_state=0, shuffle=False)
>>> clf = BaggingClassifier(base_estimator=SVC(),
... n_estimators=10, random_state=0).fit(X, y)
>>> clf.predict([[0, 0, 0, 0]])
array([1])
BaggingRegressor : A Bagging regressor.

References
----------
Expand All @@ -633,6 +625,19 @@ class BaggingClassifier(ClassifierMixin, BaseBagging):

.. [4] G. Louppe and P. Geurts, "Ensembles on Random Patches", Machine
Learning and Knowledge Discovery in Databases, 346-361, 2012.

Examples
--------
>>> from sklearn.svm import SVC
>>> from sklearn.ensemble import BaggingClassifier
>>> from sklearn.datasets import make_classification
>>> X, y = make_classification(n_samples=100, n_features=4,
... n_informative=2, n_redundant=0,
... random_state=0, shuffle=False)
>>> clf = BaggingClassifier(base_estimator=SVC(),
... n_estimators=10, random_state=0).fit(X, y)
>>> clf.predict([[0, 0, 0, 0]])
array([1])
"""

def __init__(
Expand Down Expand Up @@ -866,7 +871,6 @@ def decision_function(self, X):
to the classes in sorted order, as they appear in the attribute
``classes_``. Regression and binary classification are special
cases with ``k == 1``, otherwise ``k==n_classes``.

"""
check_is_fitted(self)

Expand Down
0