MaxAbsScaler¶
yohou.preprocessing.sklearn_wrappers.MaxAbsScaler
¶
Bases: SklearnScaler
Scale each feature by its maximum absolute value.
This estimator scales and translates each feature individually such that the maximal absolute value of each feature in the training set will be 1.0. It does not shift/center the data, and thus does not destroy any sparsity.
MaxAbsScaler doesn't reduce the effect of outliers; it only linearly
scales them down.
This is a Yohou wrapper that preserves the polars DataFrame structure and "time" column.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
clip
|
bool
|
Set to True to clip transformed values of held-out data to [-1, 1]. |
False
|
Attributes¶
| Name | Type | Description |
|---|---|---|
instance_ |
MaxAbsScaler
|
The fitted sklearn MaxAbsScaler instance. |
scale_ |
ndarray of shape (n_features,)
|
Per feature relative scaling of the data. |
max_abs_ |
ndarray of shape (n_features,)
|
Per feature maximum absolute value. |
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.preprocessing import MaxAbsScaler
>>> X = pl.DataFrame({
... "time": [datetime(2024, 1, i) for i in range(1, 6)],
... "value": [-50.0, -25.0, 0.0, 25.0, 50.0],
... })
>>> scaler = MaxAbsScaler()
>>> scaler.fit(X)
MaxAbsScaler(...)
>>> X_scaled = scaler.transform(X)
>>> # Values scaled to [-1, 1] range
>>> X_scaled["value"].max()
1.0
>>> X_scaled["value"].min()
-1.0
See Also¶
MinMaxScaler: Scale features to a given range.StandardScaler: Standardize features by removing mean and scaling to unit variance.