@@ -811,6 +811,10 @@ class TransformerMixin(_SetOutputMixin):
811811 If :term:`get_feature_names_out` is defined, then `BaseEstimator` will
812812 automatically wrap `transform` and `fit_transform` to follow the `set_output`
813813 API. See the :ref:`developer_api_set_output` for details.
814+
815+ :class:`base.OneToOneFeatureMixin` and
816+ :class:`base.ClassNamePrefixFeaturesOutMixin` are helpful mixins for
817+ defining :term:`get_feature_names_out`.
814818 """
815819
816820 def fit_transform (self , X , y = None , ** fit_params ):
@@ -847,11 +851,11 @@ def fit_transform(self, X, y=None, **fit_params):
847851 return self .fit (X , y , ** fit_params ).transform (X )
848852
849853
850- class _OneToOneFeatureMixin :
854+ class OneToOneFeatureMixin :
851855 """Provides `get_feature_names_out` for simple transformers.
852856
853- Assumes there's a 1-to-1 correspondence between input features
854- and output features.
857+ This mixin assumes there's a 1-to-1 correspondence between input features
858+ and output features, such as :class:`~preprocessing.StandardScaler` .
855859 """
856860
857861 def get_feature_names_out (self , input_features = None ):
@@ -877,15 +881,26 @@ def get_feature_names_out(self, input_features=None):
877881 return _check_feature_names_in (self , input_features )
878882
879883
880- class _ClassNamePrefixFeaturesOutMixin :
884+ class ClassNamePrefixFeaturesOutMixin :
881885 """Mixin class for transformers that generate their own names by prefixing.
882886
883- Assumes that `_n_features_out` is defined for the estimator.
887+ This mixin is useful when the transformer needs to generate its own feature
888+ names out, such as :class:`~decomposition.PCA`. For example, if
889+ :class:`~decomposition.PCA` outputs 3 features, then the generated feature
890+ names out are: `["pca0", "pca1", "pca2"]`.
891+
892+ This mixin assumes that a `_n_features_out` attribute is defined when the
893+ transformer is fitted. `_n_features_out` is the number of output features
894+ that the transformer will return in `transform` of `fit_transform`.
884895 """
885896
886897 def get_feature_names_out (self , input_features = None ):
887898 """Get output feature names for transformation.
888899
900+ The feature names out will prefixed by the lowercased class name. For
901+ example, if the transformer outputs 3 features, then the feature names
902+ out are: `["class_name0", "class_name1", "class_name2"]`.
903+
889904 Parameters
890905 ----------
891906 input_features : array-like of str or None, default=None
0 commit comments