From 6bd9df5a286077ace9685072211fa02becf1dbd8 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 17 Sep 2021 16:10:21 -0400 Subject: [PATCH 01/12] ENH Adds feature_names_out to preprocessing module --- sklearn/preprocessing/_data.py | 25 ++++++++++++++++++-- sklearn/preprocessing/_encoders.py | 4 ++-- sklearn/preprocessing/tests/test_data.py | 16 +++++++++++++ sklearn/preprocessing/tests/test_encoders.py | 12 ++++++++++ sklearn/tests/test_common.py | 1 - sklearn/utils/validation.py | 17 ++++++++++--- 6 files changed, 67 insertions(+), 8 deletions(-) diff --git a/sklearn/preprocessing/_data.py b/sklearn/preprocessing/_data.py index ecce5e6b6d096..7c718b33e9156 100644 --- a/sklearn/preprocessing/_data.py +++ b/sklearn/preprocessing/_data.py @@ -35,6 +35,7 @@ check_random_state, _check_sample_weight, FLOAT_DTYPES, + _check_feature_names_in, ) from ._encoders import OneHotEncoder @@ -1833,7 +1834,7 @@ def normalize(X, norm="l2", *, axis=1, copy=True, return_norm=False): return X -class Normalizer(TransformerMixin, BaseEstimator): +class Normalizer(_OneToOneFeatureMixin, TransformerMixin, BaseEstimator): """Normalize samples individually to unit norm. Each sample (i.e. each row of the data matrix) with at least one @@ -2004,7 +2005,7 @@ def binarize(X, *, threshold=0.0, copy=True): return X -class Binarizer(TransformerMixin, BaseEstimator): +class Binarizer(_OneToOneFeatureMixin, TransformerMixin, BaseEstimator): """Binarize data (set feature values to 0 or 1) according to a threshold. Values greater than the threshold map to 1, while values less than @@ -2266,6 +2267,26 @@ def transform(self, K, copy=True): return K + def get_feature_names_out(self, input_features=None): + """Get output feature names for transformation. + + Parameters + ---------- + input_features : array-like of str or None, default=None + Not used, present here for API consistency by convention. + + Returns + ------- + feature_names_out : ndarray of str objects + Transformed feature names. + """ + _check_feature_names_in(self, input_features, generate_names=False) + class_name = self.__class__.__name__.lower() + return np.asarray( + [f"{class_name}{i}" for i in range(self.n_features_in_)], + dtype=object, + ) + def _more_tags(self): return {"pairwise": True} diff --git a/sklearn/preprocessing/_encoders.py b/sklearn/preprocessing/_encoders.py index df35c7b811443..8893a153e3f20 100644 --- a/sklearn/preprocessing/_encoders.py +++ b/sklearn/preprocessing/_encoders.py @@ -7,7 +7,7 @@ from scipy import sparse import numbers -from ..base import BaseEstimator, TransformerMixin +from ..base import BaseEstimator, TransformerMixin, _OneToOneFeatureMixin from ..utils import check_array, is_scalar_nan from ..utils.deprecation import deprecated from ..utils.validation import check_is_fitted @@ -734,7 +734,7 @@ def get_feature_names_out(self, input_features=None): return np.asarray(feature_names, dtype=object) -class OrdinalEncoder(_BaseEncoder): +class OrdinalEncoder(_OneToOneFeatureMixin, _BaseEncoder): """ Encode categorical features as an integer array. diff --git a/sklearn/preprocessing/tests/test_data.py b/sklearn/preprocessing/tests/test_data.py index 9e7a8a174c182..7868d86967bf3 100644 --- a/sklearn/preprocessing/tests/test_data.py +++ b/sklearn/preprocessing/tests/test_data.py @@ -45,6 +45,7 @@ from sklearn.preprocessing import power_transform from sklearn.preprocessing._data import _handle_zeros_in_scale from sklearn.preprocessing._data import BOUNDS_THRESHOLD +from sklearn.metrics.pairwise import linear_kernel from sklearn.exceptions import NotFittedError @@ -2672,6 +2673,8 @@ def test_one_to_one_features(Transformer): StandardScaler, QuantileTransformer, PowerTransformer, + Normalizer, + Binarizer, ], ) def test_one_to_one_features_pandas(Transformer): @@ -2691,3 +2694,16 @@ def test_one_to_one_features_pandas(Transformer): with pytest.raises(ValueError, match=msg): invalid_names = list("abcd") tr.get_feature_names_out(invalid_names) + + +def test_kernel_centerer_feature_names_out(): + """Test that kernel centerer feature_names_out""" + + rng = np.random.RandomState(0) + X = rng.random_sample((6, 4)) + X_pairwise = linear_kernel(X) + centerer = KernelCenterer().fit(X_pairwise) + + names_out = centerer.get_feature_names_out() + samples_out2 = X_pairwise.shape[1] + assert_array_equal(names_out, [f"kernelcenterer{i}" for i in range(samples_out2)]) diff --git a/sklearn/preprocessing/tests/test_encoders.py b/sklearn/preprocessing/tests/test_encoders.py index 0429dc00c2322..9e20a5f15e40e 100644 --- a/sklearn/preprocessing/tests/test_encoders.py +++ b/sklearn/preprocessing/tests/test_encoders.py @@ -1387,3 +1387,15 @@ def test_ordinal_encoder_python_integer(): assert_array_equal(encoder.categories_, np.sort(X, axis=0).T) X_trans = encoder.transform(X) assert_array_equal(X_trans, [[0], [3], [2], [1]]) + + +def test_ordinal_encoder_features_names_out_pandas(): + """Check feature names out is same as the input""" + pd = pytest.importorskip("pandas") + + names = ["b", "c", "a"] + X = pd.DataFrame([[1, 2, 3]], columns=names) + enc = OrdinalEncoder().fit(X) + + feature_names_out = enc.get_feature_names_out() + assert_array_equal(names, feature_names_out) diff --git a/sklearn/tests/test_common.py b/sklearn/tests/test_common.py index 4f6818081c67d..0b9f7e422c458 100644 --- a/sklearn/tests/test_common.py +++ b/sklearn/tests/test_common.py @@ -368,7 +368,6 @@ def test_pandas_column_name_consistency(estimator): "impute", "isotonic", "kernel_approximation", - "preprocessing", "manifold", "neighbors", "neural_network", diff --git a/sklearn/utils/validation.py b/sklearn/utils/validation.py index f81fc2fdba685..f6a8987478291 100644 --- a/sklearn/utils/validation.py +++ b/sklearn/utils/validation.py @@ -1693,8 +1693,10 @@ def _get_feature_names(X): return feature_names -def _check_feature_names_in(estimator, input_features=None): - """Get output feature names for transformation. +def _check_feature_names_in(estimator, input_features=None, *, generate_names=True): + """Check input_features and generate names if needed. + + Commonly used in :term:`get_feature_names_out`. Parameters ---------- @@ -1707,9 +1709,15 @@ def _check_feature_names_in(estimator, input_features=None): - If `input_features` is an array-like, then `input_features` must match `feature_names_in_` if `feature_names_in_` is defined. + generate_names : bool, default=True + Wether to generate names when `input_features` is `None` and + `estimator.feature_names_in_` is not defined. This is useful for jransformers + validates `input_features` but does not require them in + :term:`get_feature_names_out` i.e. `PCA`. + Returns ------- - feature_names_in : ndarray of str + feature_names_in : ndarray of str or `None` Feature names in. """ @@ -1733,6 +1741,9 @@ def _check_feature_names_in(estimator, input_features=None): if feature_names_in_ is not None: return feature_names_in_ + if not generate_names: + return + # Generates feature names if `n_features_in_` is defined if n_features_in_ is None: raise ValueError("Unable to generate feature names without n_features_in_") From fcd7e70c7e4a44d62cd7595aa386e4683eb60f34 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 17 Sep 2021 16:57:56 -0400 Subject: [PATCH 02/12] DOC Adds whats new --- doc/whats_new/v1.1.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/whats_new/v1.1.rst b/doc/whats_new/v1.1.rst index 9c1084e393e8d..5f4841d925228 100644 --- a/doc/whats_new/v1.1.rst +++ b/doc/whats_new/v1.1.rst @@ -38,6 +38,15 @@ Changelog :pr:`123456` by :user:`Joe Bloggs `. where 123456 is the *pull request* number, not the issue number. +:mod:`sklearn.preprocessing` +............................ + +- |API| Adds :meth:`get_feature_names_out` to + :class:`preprocessing.Normalizer`, + :class:`preprocessing.KernelCenterer`, + :class:`preprocessing.OrdinalEncoder`, and + :class:`preprocessing.Binarizer`. :pr:`xxxxx` by `Thomas Fan`_. + :mod:`sklearn.utils` .................... From 88ea6adbc365a8f560727276bb3f0d7b253dc2ac Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 17 Sep 2021 16:58:30 -0400 Subject: [PATCH 03/12] DOC Adds whats new --- doc/whats_new/v1.1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats_new/v1.1.rst b/doc/whats_new/v1.1.rst index 5f4841d925228..9965740f5cea9 100644 --- a/doc/whats_new/v1.1.rst +++ b/doc/whats_new/v1.1.rst @@ -45,7 +45,7 @@ Changelog :class:`preprocessing.Normalizer`, :class:`preprocessing.KernelCenterer`, :class:`preprocessing.OrdinalEncoder`, and - :class:`preprocessing.Binarizer`. :pr:`xxxxx` by `Thomas Fan`_. + :class:`preprocessing.Binarizer`. :pr:`21079` by `Thomas Fan`_. :mod:`sklearn.utils` .................... From a704c828f8fa5a19186f7788ac1dc02ecb50376f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=B0=20=28Zhao=20Feng=29?= <616545598@qq.com> Date: Fri, 24 Sep 2021 19:57:32 +0800 Subject: [PATCH 04/12] DOC remove redundant code in GPR example (#21133) --- examples/gaussian_process/plot_gpr_prior_posterior.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/gaussian_process/plot_gpr_prior_posterior.py b/examples/gaussian_process/plot_gpr_prior_posterior.py index c9f12c16819fd..bd82613a20a45 100644 --- a/examples/gaussian_process/plot_gpr_prior_posterior.py +++ b/examples/gaussian_process/plot_gpr_prior_posterior.py @@ -57,9 +57,6 @@ def plot_gpr_samples(gpr_model, n_samples, ax): y_mean, y_std = gpr_model.predict(X, return_std=True) y_samples = gpr_model.sample_y(X, n_samples) - y_mean, y_std = gpr_model.predict(X, return_std=True) - y_samples = gpr_model.sample_y(X, n_samples) - for idx, single_prior in enumerate(y_samples.T): ax.plot( x, From 7eba091cd9923d99bebe0395e2c746dc246b8607 Mon Sep 17 00:00:00 2001 From: Niket Jain <51831161+nikJ13@users.noreply.github.com> Date: Fri, 24 Sep 2021 17:29:04 +0530 Subject: [PATCH 05/12] DOC Ensures that RandomizedSearchCV passes numpydoc validation (#21131) --- maint_tools/test_docstrings.py | 1 - sklearn/model_selection/_search.py | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index afa328f68ba8f..90d70a7c18101 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -32,7 +32,6 @@ "PatchExtractor", "PolynomialFeatures", "QuadraticDiscriminantAnalysis", - "RandomizedSearchCV", "RobustScaler", "SelfTrainingClassifier", "SparseRandomProjection", diff --git a/sklearn/model_selection/_search.py b/sklearn/model_selection/_search.py index 746ec5e9a0813..c13e5b6643ce1 100644 --- a/sklearn/model_selection/_search.py +++ b/sklearn/model_selection/_search.py @@ -1420,7 +1420,7 @@ class RandomizedSearchCV(BaseSearchCV): Parameters ---------- - estimator : estimator object. + estimator : estimator object A object of that type is instantiated for each grid point. This is assumed to implement the scikit-learn estimator interface. Either estimator needs to provide a ``score`` function, @@ -1692,6 +1692,12 @@ class RandomizedSearchCV(BaseSearchCV): .. versionadded:: 1.0 + See Also + -------- + GridSearchCV : Does exhaustive search over a grid of parameters. + ParameterSampler : A generator over parameter settings, constructed from + param_distributions. + Notes ----- The parameters selected are those that maximize the score of the held-out @@ -1705,12 +1711,6 @@ class RandomizedSearchCV(BaseSearchCV): `pre_dispatch` many times. A reasonable value for `pre_dispatch` is `2 * n_jobs`. - See Also - -------- - GridSearchCV : Does exhaustive search over a grid of parameters. - ParameterSampler : A generator over parameter settings, constructed from - param_distributions. - Examples -------- >>> from sklearn.datasets import load_iris From 19e4ff1e0e34ec6dccadf69e825563ac7232242b Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 24 Sep 2021 09:38:11 -0400 Subject: [PATCH 06/12] CLN Address comments --- sklearn/utils/validation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sklearn/utils/validation.py b/sklearn/utils/validation.py index f6a8987478291..c27930600a9b4 100644 --- a/sklearn/utils/validation.py +++ b/sklearn/utils/validation.py @@ -1710,9 +1710,9 @@ def _check_feature_names_in(estimator, input_features=None, *, generate_names=Tr match `feature_names_in_` if `feature_names_in_` is defined. generate_names : bool, default=True - Wether to generate names when `input_features` is `None` and - `estimator.feature_names_in_` is not defined. This is useful for jransformers - validates `input_features` but does not require them in + Whether to generate names when `input_features` is `None` and + `estimator.feature_names_in_` is not defined. This is useful for transformers + that validates `input_features` but does not require them in :term:`get_feature_names_out` i.e. `PCA`. Returns From 82d19c7f1be17eb7fb386e1e380ac1c5c06cbe8c Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 19 Oct 2021 13:04:31 -0400 Subject: [PATCH 07/12] DOC Fix grammar --- sklearn/utils/validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/utils/validation.py b/sklearn/utils/validation.py index 95ee51689862b..5259186a313d2 100644 --- a/sklearn/utils/validation.py +++ b/sklearn/utils/validation.py @@ -1714,7 +1714,7 @@ def _check_feature_names_in(estimator, input_features=None, *, generate_names=Tr generate_names : bool, default=True Whether to generate names when `input_features` is `None` and `estimator.feature_names_in_` is not defined. This is useful for transformers - that validates `input_features` but does not require them in + that validates `input_features` but do not require them in :term:`get_feature_names_out` i.e. `PCA`. Returns From ff31d1b786f5345f5194d0d43289ce5c8076d7f5 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 20 Oct 2021 13:51:30 -0400 Subject: [PATCH 08/12] CLN Address comments --- sklearn/preprocessing/_data.py | 2 +- sklearn/preprocessing/tests/test_data.py | 2 +- sklearn/preprocessing/tests/test_encoders.py | 2 +- sklearn/utils/validation.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sklearn/preprocessing/_data.py b/sklearn/preprocessing/_data.py index 44c6d5ebc60ad..c55c62cf5caa0 100644 --- a/sklearn/preprocessing/_data.py +++ b/sklearn/preprocessing/_data.py @@ -2259,7 +2259,7 @@ def transform(self, K, copy=True): """ check_is_fitted(self) - K = self._validate_data(K, copy=copy, dtype=FLOAT_DTYPES, reset=False) + K = check_array(K, copy=copy, dtype=FLOAT_DTYPES) K_pred_cols = (np.sum(K, axis=1) / self.K_fit_rows_.shape[0])[:, np.newaxis] diff --git a/sklearn/preprocessing/tests/test_data.py b/sklearn/preprocessing/tests/test_data.py index 7868d86967bf3..764ef2df653e0 100644 --- a/sklearn/preprocessing/tests/test_data.py +++ b/sklearn/preprocessing/tests/test_data.py @@ -2697,7 +2697,7 @@ def test_one_to_one_features_pandas(Transformer): def test_kernel_centerer_feature_names_out(): - """Test that kernel centerer feature_names_out""" + """Test that kernel centerer `feature_names_out`.""" rng = np.random.RandomState(0) X = rng.random_sample((6, 4)) diff --git a/sklearn/preprocessing/tests/test_encoders.py b/sklearn/preprocessing/tests/test_encoders.py index 1a768301c4e5e..27c52088f80d9 100644 --- a/sklearn/preprocessing/tests/test_encoders.py +++ b/sklearn/preprocessing/tests/test_encoders.py @@ -1390,7 +1390,7 @@ def test_ordinal_encoder_python_integer(): def test_ordinal_encoder_features_names_out_pandas(): - """Check feature names out is same as the input""" + """Check feature names out is same as the input.""" pd = pytest.importorskip("pandas") names = ["b", "c", "a"] diff --git a/sklearn/utils/validation.py b/sklearn/utils/validation.py index 5259186a313d2..1b1641d8f4bdb 100644 --- a/sklearn/utils/validation.py +++ b/sklearn/utils/validation.py @@ -1696,7 +1696,7 @@ def _get_feature_names(X): def _check_feature_names_in(estimator, input_features=None, *, generate_names=True): - """Check input_features and generate names if needed. + """Check `input_features` and generate names if needed. Commonly used in :term:`get_feature_names_out`. @@ -1715,7 +1715,7 @@ def _check_feature_names_in(estimator, input_features=None, *, generate_names=Tr Whether to generate names when `input_features` is `None` and `estimator.feature_names_in_` is not defined. This is useful for transformers that validates `input_features` but do not require them in - :term:`get_feature_names_out` i.e. `PCA`. + :term:`get_feature_names_out` e.g. `PCA`. Returns ------- From 01a32d3df908c6c3612df3256a50b8815bb87f13 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 20 Oct 2021 15:26:23 -0400 Subject: [PATCH 09/12] REV Revert unneeded change --- sklearn/preprocessing/_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/preprocessing/_data.py b/sklearn/preprocessing/_data.py index c55c62cf5caa0..44c6d5ebc60ad 100644 --- a/sklearn/preprocessing/_data.py +++ b/sklearn/preprocessing/_data.py @@ -2259,7 +2259,7 @@ def transform(self, K, copy=True): """ check_is_fitted(self) - K = check_array(K, copy=copy, dtype=FLOAT_DTYPES) + K = self._validate_data(K, copy=copy, dtype=FLOAT_DTYPES, reset=False) K_pred_cols = (np.sum(K, axis=1) / self.K_fit_rows_.shape[0])[:, np.newaxis] From 61cde09d9fd40d3922a6ece0dba466edc1d3bc23 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 26 Oct 2021 11:40:49 -0400 Subject: [PATCH 10/12] CLN Merge conflict --- doc/whats_new/v1.1.rst | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/whats_new/v1.1.rst b/doc/whats_new/v1.1.rst index 3a0b1cf79d768..3d7ad4a57cf1d 100644 --- a/doc/whats_new/v1.1.rst +++ b/doc/whats_new/v1.1.rst @@ -58,13 +58,6 @@ Changelog - |Fix| :class:`decomposition.FastICA` now validates input parameters in `fit` instead of `__init__`. :pr:`21432` by :user:`Hannah Bohle ` and :user:`Maren Westermann `. -:mod:`sklearn.impute` -..................... - -- |Fix| :class:`linear_model.LogisticRegression` now raises a better error - message when the solver does not support sparse matrices with int64 indices. - :pr:`21093` by `Tom Dupre la Tour`_. - :mod:`sklearn.preprocessing` ............................ @@ -73,6 +66,10 @@ Changelog :class:`preprocessing.KernelCenterer`, :class:`preprocessing.OrdinalEncoder`, and :class:`preprocessing.Binarizer`. :pr:`21079` by `Thomas Fan`_. + +:mod:`sklearn.impute` +..................... + - |API| Adds :meth:`get_feature_names_out` to :class:`impute.SimpleImputer`, :class:`impute.KNNImputer`, :class:`impute.IterativeImputer`, and :class:`impute.MissingIndicator`. :pr:`21078` by `Thomas Fan`_. From 2cd55e9b27feb8564adc8e34a08495f8a4fdd4e3 Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Mon, 6 Dec 2021 12:02:28 +0100 Subject: [PATCH 11/12] Make KernelCenterer inherit from _ClassNamePrefixFeaturesOutMixin --- sklearn/preprocessing/_data.py | 37 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/sklearn/preprocessing/_data.py b/sklearn/preprocessing/_data.py index 7437c4acfe9af..6802b4774d3ef 100644 --- a/sklearn/preprocessing/_data.py +++ b/sklearn/preprocessing/_data.py @@ -16,7 +16,12 @@ from scipy import optimize from scipy.special import boxcox -from ..base import BaseEstimator, TransformerMixin, _OneToOneFeatureMixin +from ..base import ( + BaseEstimator, + TransformerMixin, + _OneToOneFeatureMixin, + _ClassNamePrefixFeaturesOutMixin, +) from ..utils import check_array from ..utils.deprecation import deprecated from ..utils.extmath import _incremental_mean_and_var, row_norms @@ -35,7 +40,6 @@ check_random_state, _check_sample_weight, FLOAT_DTYPES, - _check_feature_names_in, ) from ._encoders import OneHotEncoder @@ -2120,7 +2124,7 @@ def _more_tags(self): return {"stateless": True} -class KernelCenterer(TransformerMixin, BaseEstimator): +class KernelCenterer(_ClassNamePrefixFeaturesOutMixin, TransformerMixin, BaseEstimator): r"""Center an arbitrary kernel matrix :math:`K`. Let define a kernel :math:`K` such that: @@ -2259,25 +2263,14 @@ def transform(self, K, copy=True): return K - def get_feature_names_out(self, input_features=None): - """Get output feature names for transformation. - - Parameters - ---------- - input_features : array-like of str or None, default=None - Not used, present here for API consistency by convention. - - Returns - ------- - feature_names_out : ndarray of str objects - Transformed feature names. - """ - _check_feature_names_in(self, input_features, generate_names=False) - class_name = self.__class__.__name__.lower() - return np.asarray( - [f"{class_name}{i}" for i in range(self.n_features_in_)], - dtype=object, - ) + @property + def _n_features_out(self): + """Number of transformed output features.""" + # Used by _ClassNamePrefixFeaturesOutMixin. This model preserves the + # number of input features but this is not a one-to-one mapping in the + # usual sense. Hence the choice not to use _OneToOneFeatureMixin to + # implement get_feature_names_out for this class. + return self.n_features_in_ def _more_tags(self): return {"pairwise": True} From 8778438b262d521bf2bd5988e7d7f70a92d62d88 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 4 Jan 2022 14:33:54 -0500 Subject: [PATCH 12/12] DOC Adjust merge --- doc/whats_new/v1.1.rst | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/doc/whats_new/v1.1.rst b/doc/whats_new/v1.1.rst index 790478e9f4015..822e6f79a9ae2 100644 --- a/doc/whats_new/v1.1.rst +++ b/doc/whats_new/v1.1.rst @@ -387,16 +387,6 @@ Changelog the model. The option is only available when `strategy` is set to `quantile`. :pr:`21445` by :user:`Felipe Bidu ` and :user:`Amanda Dsouza `. -- |Fix| :class:`preprocessing.LabelBinarizer` now validates input parameters in `fit` - instead of `__init__`. - :pr:`21434` by :user:`Krum Arnaudov `. - -- |API| Adds :meth:`get_feature_names_out` to - :class:`preprocessing.Normalizer`, - :class:`preprocessing.KernelCenterer`, - :class:`preprocessing.OrdinalEncoder`, and - :class:`preprocessing.Binarizer`. :pr:`21079` by `Thomas Fan`_. - - |Enhancement| Added the `get_feature_names_out` method and a new parameter `feature_names_out` to :class:`preprocessing.FunctionTransformer`. You can set `feature_names_out` to 'one-to-one' to use the input features names as the @@ -410,6 +400,12 @@ Changelog `fit` instead of `__init__`. :pr:`21434` by :user:`Krum Arnaudov `. +- |API| Adds :meth:`get_feature_names_out` to + :class:`preprocessing.Normalizer`, + :class:`preprocessing.KernelCenterer`, + :class:`preprocessing.OrdinalEncoder`, and + :class:`preprocessing.Binarizer`. :pr:`21079` by `Thomas Fan`_. + :mod:`sklearn.random_projection` ................................