Skip to content

ENH Checks n_features_in_ after fitting in random_projection #19541

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
5 changes: 2 additions & 3 deletions sklearn/random_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from .utils import check_random_state
from .utils.extmath import safe_sparse_dot
from .utils.random import sample_without_replacement
from .utils.validation import check_array, check_is_fitted
from .utils.validation import check_is_fitted
from .utils.validation import _deprecate_positional_args
from .exceptions import DataDimensionalityWarning

Expand Down Expand Up @@ -402,9 +402,8 @@ def transform(self, X):
X_new : {ndarray, sparse matrix} of shape (n_samples, n_components)
Projected array.
"""
X = check_array(X, accept_sparse=['csr', 'csc'])

check_is_fitted(self)
X = self._validate_data(X, accept_sparse=['csr', 'csc'], reset=False)

if X.shape[1] != self.components_.shape[1]:
raise ValueError(
Expand Down
1 change: 0 additions & 1 deletion sklearn/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ def test_search_cv(estimator, check, request):
'multiclass',
'multioutput',
'pipeline',
'random_projection',
}

N_FEATURES_IN_AFTER_FIT_ESTIMATORS = [
Expand Down