Skip to content

DOC Documents n_features_in_ in cross_decomposition #19351

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 1 commit into from
Feb 8, 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
12 changes: 12 additions & 0 deletions sklearn/cross_decomposition/_pls.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ class PLSRegression(_PLS):
n_iter_ : list of shape (n_components,)
Number of iterations of the power method for each component.

n_features_in_ : int
Number of features seen during :term:`fit`.

Examples
--------
>>> from sklearn.cross_decomposition import PLSRegression
Expand Down Expand Up @@ -647,6 +650,9 @@ class PLSCanonical(_PLS):
Number of iterations of the power method, for each
component. Empty if `algorithm='svd'`.

n_features_in_ : int
Number of features seen during :term:`fit`.

Examples
--------
>>> from sklearn.cross_decomposition import PLSCanonical
Expand Down Expand Up @@ -753,6 +759,9 @@ class CCA(_PLS):
Number of iterations of the power method, for each
component.

n_features_in_ : int
Number of features seen during :term:`fit`.

Examples
--------
>>> from sklearn.cross_decomposition import CCA
Expand Down Expand Up @@ -830,6 +839,9 @@ class PLSSVD(TransformerMixin, BaseEstimator):
(renaming of 0.26). You can just call `transform` on the training
data instead.

n_features_in_ : int
Number of features seen during :term:`fit`.

Examples
--------
>>> import numpy as np
Expand Down
41 changes: 39 additions & 2 deletions sklearn/tests/test_docstring_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,40 @@ def _construct_searchcv_instance(SearchCV):
return SearchCV(LogisticRegression(), {"C": [0.1, 1]})


N_FEATURES_MODULES_TO_IGNORE = {
'calibration',
'cluster',
'compose',
'covariance',
'decomposition',
'discriminant_analysis',
'dummy',
'ensemble',
'feature_extraction',
'feature_selection',
'gaussian_process',
'impute',
'isotonic',
'kernel_approximation',
'kernel_ridge',
'linear_model',
'manifold',
'mixture',
'model_selection',
'multiclass',
'multioutput',
'naive_bayes',
'neighbors',
'neural_network',
'pipeline',
'preprocessing',
'random_projection',
'semi_supervised',
'svm',
'tree'
}


@pytest.mark.parametrize('name, Estimator',
all_estimators())
def test_fit_docstring_attributes(name, Estimator):
Expand Down Expand Up @@ -234,10 +268,13 @@ def test_fit_docstring_attributes(name, Estimator):
else:
est.fit(X, y)

skipped_attributes = {'n_features_in_',
'x_scores_', # For PLS, TODO remove in 1.1
skipped_attributes = {'x_scores_', # For PLS, TODO remove in 1.1
'y_scores_'} # For PLS, TODO remove in 1.1

module = est.__module__.split(".")[1]
if module in N_FEATURES_MODULES_TO_IGNORE:
skipped_attributes.add("n_features_in_")

for attr in attributes:
if attr.name in skipped_attributes:
continue
Expand Down