Mixin class for transformers that generate their own names by prefixing.
This mixin is useful when the transformer needs to generate its own feature names out, such as PCA
. For example, if PCA
outputs 3 features, then the generated feature names out are: ["pca0", "pca1", "pca2"]
.
This mixin assumes that a _n_features_out
attribute is defined when the transformer is fitted. _n_features_out
is the number of output features that the transformer will return in transform
of fit_transform
.
Examples
>>> import numpy as np >>> from sklearn.base import ClassNamePrefixFeaturesOutMixin, BaseEstimator >>> class MyEstimator(ClassNamePrefixFeaturesOutMixin, BaseEstimator): ... def fit(self, X, y=None): ... self._n_features_out = X.shape[1] ... return self >>> X = np.array([[1, 2], [3, 4]]) >>> MyEstimator().fit(X).get_feature_names_out() array(['myestimator0', 'myestimator1'], dtype=object)
Get output feature names for transformation.
The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: ["class_name0", "class_name1", "class_name2"]
.
Only used to validate feature names with the names seen in fit
.
Transformed feature names.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4