Mixin class for all transformers in scikit-learn.
This mixin defines the following functionality:
a fit_transform
method that delegates to fit
and transform
;
a set_output
method to output X
as a specific container type.
If get_feature_names_out is defined, then BaseEstimator
will automatically wrap transform
and fit_transform
to follow the set_output
API. See the Developer API for set_output for details.
OneToOneFeatureMixin
and ClassNamePrefixFeaturesOutMixin
are helpful mixins for defining get_feature_names_out.
Examples
>>> import numpy as np >>> from sklearn.base import BaseEstimator, TransformerMixin >>> class MyTransformer(TransformerMixin, BaseEstimator): ... def __init__(self, *, param=1): ... self.param = param ... def fit(self, X, y=None): ... return self ... def transform(self, X): ... return np.full(shape=len(X), fill_value=self.param) >>> transformer = MyTransformer() >>> X = [[1, 2], [2, 3], [3, 4]] >>> transformer.fit_transform(X) array([1, 1, 1])
Fit to data, then transform it.
Fits transformer to X
and y
with optional parameters fit_params
and returns a transformed version of X
.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Transformed array.
Set output container.
See Introducing the set_output API for an example on how to use the API.
Configure output of transform
and fit_transform
.
"default"
: Default output format of a transformer
"pandas"
: DataFrame output
"polars"
: Polars output
None
: Transform configuration is unchanged
Added in version 1.4: "polars"
option was added.
Estimator instance.
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