Skip to content

Commit 12db86e

Browse files
authored
ENH Checks n_features_in_ after fitting in random_projection (#19541)
1 parent 052efae commit 12db86e

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

sklearn/random_projection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from .utils import check_random_state
3939
from .utils.extmath import safe_sparse_dot
4040
from .utils.random import sample_without_replacement
41-
from .utils.validation import check_array, check_is_fitted
41+
from .utils.validation import check_is_fitted
4242
from .utils.validation import _deprecate_positional_args
4343
from .exceptions import DataDimensionalityWarning
4444

@@ -402,9 +402,8 @@ def transform(self, X):
402402
X_new : {ndarray, sparse matrix} of shape (n_samples, n_components)
403403
Projected array.
404404
"""
405-
X = check_array(X, accept_sparse=['csr', 'csc'])
406-
407405
check_is_fitted(self)
406+
X = self._validate_data(X, accept_sparse=['csr', 'csc'], reset=False)
408407

409408
if X.shape[1] != self.components_.shape[1]:
410409
raise ValueError(

sklearn/tests/test_common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ def test_search_cv(estimator, check, request):
272272
'multiclass',
273273
'multioutput',
274274
'pipeline',
275-
'random_projection',
276275
}
277276

278277
N_FEATURES_IN_AFTER_FIT_ESTIMATORS = [

0 commit comments

Comments
 (0)