SklearnScaler¶
yohou.preprocessing.SklearnScaler
¶
Bases: SklearnTransformer
Wrapper to integrate sklearn scalers into the Yohou pipeline.
Preserves the polars DataFrame structure and "time" column while applying sklearn scaling transformations to all non-time columns.
This class can be used to:
- Wrap any sklearn-compatible scaler for use in yohou pipelines
- Serve as a base class for creating yohou scaler extensions
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
scaler
|
type
|
The sklearn scaler class to wrap. Must be a subclass of
|
None
|
**params
|
dict
|
Parameters passed to the underlying sklearn scaler constructor. See the documentation of the specific scaler for available parameters. |
{}
|
Attributes ¶
| Name | Type | Description |
|---|---|---|
instance_ |
TransformerMixin
|
The fitted sklearn scaler instance (created by |
Examples ¶
>>> import polars as pl
>>> from datetime import datetime
>>> from sklearn.preprocessing import StandardScaler as SklearnStandardScaler
>>> from yohou.preprocessing import SklearnScaler
>>> X = pl.DataFrame({
... "time": [datetime(2024, 1, i) for i in range(1, 6)],
... "value": [10.0, 20.0, 30.0, 40.0, 50.0],
... })
>>> scaler = SklearnScaler(scaler=SklearnStandardScaler, with_mean=True)
>>> scaler.fit(X)
SklearnScaler(...)
>>> X_scaled = scaler.transform(X)
>>> "time" in X_scaled.columns
True
See Also ¶
StandardScaler: Pre-configured wrapper for sklearn's StandardScaler.MinMaxScaler: Pre-configured wrapper for sklearn's MinMaxScaler.RobustScaler: Pre-configured wrapper for sklearn's RobustScaler.MaxAbsScaler: Pre-configured wrapper for sklearn's MaxAbsScaler.