SingleColumnTransformer#
- class skrub.core.SingleColumnTransformer[source]#
Base class for single-column transformers.
Such transformers are applied independently to each column by
ApplyToCols; see the docstring ofApplyToColsfor more information.Single-column transformers are not required to inherit from this class in order to work with
ApplyToCols, however doing so avoids some boilerplate:The required
__single_column_transformer__attribute is set.fitis defined (callsfit_transformand discards the result).fit,transformandfit_transformare wrapped to checkthat the input is a single column and raise a
ValueErrorwith a helpful message when it is not.
- A note about single-column transformers (vs dataframe transformers)
is added after the summary line of the docstring.
Subclasses must define
fit_transformandtransform(or inherit them from another superclass).Methods
fit(column[, y])Fit the transformer.
get_feature_names_out([input_features])Get the output feature names.
get_params([deep])Get parameters for this estimator.
set_output(*[, transform])Default no-op implementation for set_output.
set_params(**params)Set the parameters of this estimator.
- fit(column, y=None, **kwargs)[source]#
Fit the transformer.
This default implementation simply calls
fit_transform()and returnsself.Subclasses should implement
fit_transformandtransform.- Parameters:
- columna pandas or polars
Series Unlike most scikit-learn transformers, single-column transformers transform a single column, not a whole dataframe.
- ycolumn or dataframe
Prediction targets.
- **kwargs
Extra named arguments are passed to
self.fit_transform().
- columna pandas or polars
- Returns:
- self
The fitted transformer.
- get_feature_names_out(input_features=None)[source]#
Get the output feature names.
- Parameters:
- input_featuresarray_like of
str, default=None Input feature names. Ignored.
- input_featuresarray_like of
- Returns:
- set_output(*, transform=None)[source]#
Default no-op implementation for set_output.
Skrub transformers already output dataframes of the correct type by default so there is usually no need for set_output to do anything.
Subclasses are of course free to redefine set_output (e.g. by inheriting from TransformerMixin before SingleColumnTransformer).
- set_params(**params)[source]#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
- **params
dict Estimator parameters.
- **params
- Returns:
- selfestimator instance
Estimator instance.