Skip to content

Commit baa90d4

Browse files
thomasjpfanogrisel
andauthored
API Adds feature_names_in_ to kernel_approximation (#20841)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
1 parent 7e7cdd6 commit baa90d4

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

sklearn/kernel_approximation.py

+30
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ class PolynomialCountSketch(BaseEstimator, TransformerMixin):
8383
8484
.. versionadded:: 0.24
8585
86+
feature_names_in_ : ndarray of shape (`n_features_in_`,)
87+
Names of features seen during :term:`fit`. Defined only when `X`
88+
has feature names that are all strings.
89+
90+
.. versionadded:: 1.0
91+
8692
See Also
8793
--------
8894
AdditiveChi2Sampler : Approximate feature map for additive chi2 kernel.
@@ -256,6 +262,12 @@ class RBFSampler(TransformerMixin, BaseEstimator):
256262
257263
.. versionadded:: 0.24
258264
265+
feature_names_in_ : ndarray of shape (`n_features_in_`,)
266+
Names of features seen during :term:`fit`. Defined only when `X`
267+
has feature names that are all strings.
268+
269+
.. versionadded:: 1.0
270+
259271
See Also
260272
--------
261273
AdditiveChi2Sampler : Approximate feature map for additive chi2 kernel.
@@ -386,6 +398,12 @@ class SkewedChi2Sampler(TransformerMixin, BaseEstimator):
386398
387399
.. versionadded:: 0.24
388400
401+
feature_names_in_ : ndarray of shape (`n_features_in_`,)
402+
Names of features seen during :term:`fit`. Defined only when `X`
403+
has feature names that are all strings.
404+
405+
.. versionadded:: 1.0
406+
389407
See Also
390408
--------
391409
AdditiveChi2Sampler : Approximate feature map for additive chi2 kernel.
@@ -520,6 +538,12 @@ class AdditiveChi2Sampler(TransformerMixin, BaseEstimator):
520538
521539
.. versionadded:: 0.24
522540
541+
feature_names_in_ : ndarray of shape (`n_features_in_`,)
542+
Names of features seen during :term:`fit`. Defined only when `X`
543+
has feature names that are all strings.
544+
545+
.. versionadded:: 1.0
546+
523547
See Also
524548
--------
525549
SkewedChi2Sampler : A Fourier-approximation to a non-additive variant of
@@ -764,6 +788,12 @@ class Nystroem(TransformerMixin, BaseEstimator):
764788
765789
.. versionadded:: 0.24
766790
791+
feature_names_in_ : ndarray of shape (`n_features_in_`,)
792+
Names of features seen during :term:`fit`. Defined only when `X`
793+
has feature names that are all strings.
794+
795+
.. versionadded:: 1.0
796+
767797
See Also
768798
--------
769799
AdditiveChi2Sampler : Approximate feature map for additive chi2 kernel.

sklearn/tests/test_common.py

-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ def test_check_n_features_in_after_fitting(estimator):
326326
COLUMN_NAME_MODULES_TO_IGNORE = {
327327
"compose",
328328
"feature_extraction",
329-
"kernel_approximation",
330329
"model_selection",
331330
}
332331

sklearn/utils/estimator_checks.py

+3
Original file line numberDiff line numberDiff line change
@@ -3722,6 +3722,9 @@ def check_dataframe_column_names_consistency(name, estimator_orig):
37223722
set_random_state(estimator)
37233723

37243724
X_orig = rng.normal(size=(150, 8))
3725+
3726+
# Some picky estimators (e.g. SkewedChi2Sampler) only accept skewed positive data.
3727+
X_orig -= X_orig.min() + 0.5
37253728
X_orig = _enforce_estimator_tags_x(estimator, X_orig)
37263729
X_orig = _pairwise_estimator_convert_X(X_orig, estimator)
37273730
n_samples, n_features = X_orig.shape

0 commit comments

Comments
 (0)