Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST Add test for documentation of the classes_ attribute #16277

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
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
2 changes: 2 additions & 0 deletions sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,8 @@ class HistGradientBoostingClassifier(BaseHistGradientBoosting,

Attributes
----------
classes_ : array, shape = (n_classes,)
Class labels.
n_iter_ : int
The number of estimators as selected by early stopping (if
n_iter_no_change is not None). Otherwise it corresponds to max_iter.
Expand Down
3 changes: 3 additions & 0 deletions sklearn/ensemble/_stacking.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ class StackingClassifier(ClassifierMixin, _BaseStacking):

Attributes
----------
classes_ : array, shape = (n_classes,)
Class labels.

estimators_ : list of estimators
The elements of the estimators parameter, having been fitted on the
training data. If an estimator has been set to `'drop'`, it
Expand Down
3 changes: 3 additions & 0 deletions sklearn/multioutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ class MultiOutputClassifier(ClassifierMixin, _MultiOutputEstimator):

Attributes
----------
classes_ : array, shape = (n_classes,)
Class labels.

estimators_ : list of ``n_output`` estimators
Estimators used for predictions.

Expand Down
13 changes: 13 additions & 0 deletions sklearn/tests/test_docstring_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sklearn.utils._testing import check_docstring_parameters
from sklearn.utils._testing import _get_func_name
from sklearn.utils._testing import ignore_warnings
from sklearn.utils._testing import all_estimators
from sklearn.utils.deprecation import _is_deprecated
from sklearn.externals._pep562 import Pep562

Expand Down Expand Up @@ -160,3 +161,15 @@ def test_tabs():
assert '\t' not in source, ('"%s" has tabs, please remove them ',
'or add it to theignore list'
% modname)


@pytest.mark.parametrize('name, Classifier',
all_estimators(type_filter='classifier'))
def test_classifier_docstring_attributes(name, Classifier):
docscrape = pytest.importorskip('numpydoc.docscrape')
from numpydoc import docscrape

doc = docscrape.ClassDoc(Classifier)
attributes = doc['Attributes']
assert attributes
assert 'classes_' in [att.name for att in attributes]
5 changes: 5 additions & 0 deletions sklearn/utils/_mocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class CheckingClassifier(ClassifierMixin, BaseEstimator):
check_X
foo_param
expected_fit_params

Attributes
----------
classes_

"""
def __init__(self, check_y=None, check_X=None, foo_param=0,
expected_fit_params=None):
Expand Down