diff --git a/sklearn/kernel_approximation.py b/sklearn/kernel_approximation.py index 08957191ba4b8..eb7930f4db319 100644 --- a/sklearn/kernel_approximation.py +++ b/sklearn/kernel_approximation.py @@ -83,6 +83,12 @@ class PolynomialCountSketch(BaseEstimator, TransformerMixin): .. versionadded:: 0.24 + feature_names_in_ : ndarray of shape (`n_features_in_`,) + Names of features seen during :term:`fit`. Defined only when `X` + has feature names that are all strings. + + .. versionadded:: 1.0 + See Also -------- AdditiveChi2Sampler : Approximate feature map for additive chi2 kernel. @@ -256,6 +262,12 @@ class RBFSampler(TransformerMixin, BaseEstimator): .. versionadded:: 0.24 + feature_names_in_ : ndarray of shape (`n_features_in_`,) + Names of features seen during :term:`fit`. Defined only when `X` + has feature names that are all strings. + + .. versionadded:: 1.0 + See Also -------- AdditiveChi2Sampler : Approximate feature map for additive chi2 kernel. @@ -386,6 +398,12 @@ class SkewedChi2Sampler(TransformerMixin, BaseEstimator): .. versionadded:: 0.24 + feature_names_in_ : ndarray of shape (`n_features_in_`,) + Names of features seen during :term:`fit`. Defined only when `X` + has feature names that are all strings. + + .. versionadded:: 1.0 + See Also -------- AdditiveChi2Sampler : Approximate feature map for additive chi2 kernel. @@ -520,6 +538,12 @@ class AdditiveChi2Sampler(TransformerMixin, BaseEstimator): .. versionadded:: 0.24 + feature_names_in_ : ndarray of shape (`n_features_in_`,) + Names of features seen during :term:`fit`. Defined only when `X` + has feature names that are all strings. + + .. versionadded:: 1.0 + See Also -------- SkewedChi2Sampler : A Fourier-approximation to a non-additive variant of @@ -764,6 +788,12 @@ class Nystroem(TransformerMixin, BaseEstimator): .. versionadded:: 0.24 + feature_names_in_ : ndarray of shape (`n_features_in_`,) + Names of features seen during :term:`fit`. Defined only when `X` + has feature names that are all strings. + + .. versionadded:: 1.0 + See Also -------- AdditiveChi2Sampler : Approximate feature map for additive chi2 kernel. diff --git a/sklearn/tests/test_common.py b/sklearn/tests/test_common.py index 008bdee7e646b..6c2d58266260c 100644 --- a/sklearn/tests/test_common.py +++ b/sklearn/tests/test_common.py @@ -327,7 +327,6 @@ def test_check_n_features_in_after_fitting(estimator): "compose", "ensemble", "feature_extraction", - "kernel_approximation", "model_selection", "multiclass", "multioutput", diff --git a/sklearn/utils/estimator_checks.py b/sklearn/utils/estimator_checks.py index cf88785807d06..5d09b265ee6fc 100644 --- a/sklearn/utils/estimator_checks.py +++ b/sklearn/utils/estimator_checks.py @@ -3722,6 +3722,9 @@ def check_dataframe_column_names_consistency(name, estimator_orig): set_random_state(estimator) X_orig = rng.normal(size=(150, 8)) + + # Some picky estimators (e.g. SkewedChi2Sampler) only accept skewed positive data. + X_orig -= X_orig.min() + 0.5 X_orig = _enforce_estimator_tags_x(estimator, X_orig) X_orig = _pairwise_estimator_convert_X(X_orig, estimator) n_samples, n_features = X_orig.shape