Zero-centered numeric data
Features are already centered around zero and need comparable magnitudes without mean subtraction.
Scikit-Learn · Class
MaxAbsScaler scales each feature by its largest absolute training value. It preserves zero-centered structure and sparsity because it does not subtract feature means.
MaxAbsScaler learns the largest absolute value in each feature during fit and uses those values to scale later data. It does not subtract feature means, so zero values remain zero; this also lets it preserve sparsity for supported sparse inputs.
class sklearn.preprocessing.MaxAbsScaler(*, copy=True, clip=False)| Name | Type | Description |
|---|---|---|
copy | bool, default=True | Whether to copy the input before transforming; default is True. |
clip | bool, default=False | Whether to clip transformed values to the fitted range; default is False. |
Transformed data with the same shape as the input; the class page documents transform as returning an array or sparse matrix.
from sklearn.preprocessing import MaxAbsScaler
X = [[1., -1., 2.], [2., 0., 0.], [0., 1., -1.]]
scaler = MaxAbsScaler().fit(X)
X_scaled = scaler.transform(X)
print(X_scaled)Fits per-feature maximum absolute values, then transforms the data by dividing each feature by its fitted maximum.
Features are already centered around zero and need comparable magnitudes without mean subtraction.
A dataset is stored as CSR or CSC and scaling must retain sparse structure.
A preprocessing pipeline needs reusable feature scales learned from training data.
It divides each feature by that feature's maximum absolute training value, making the largest magnitude equal to 1. It does not center the features.
Follow-up: Why can it preserve sparse structure? Because it scales existing values without subtracting a mean, so stored zero entries remain zero.
Call fit or fit_transform on training data, then call transform on new data. The learned per-feature scales are reused for later inputs.
Follow-up: What leakage risk must be avoided? Fit only on the training partition; fitting before the split lets test information influence the learned scales.
It supports sparse CSR and CSC matrices and is intended for data already centered at zero or sparse data. Unlike a centering transformer, it does not destroy sparsity.
Follow-up: When might another scaler be preferable? Use one with centering or robust statistics when zero-centered scaling is inappropriate or outliers need stronger treatment.
sklearn.preprocessing.maxabs_scalesklearn.preprocessing.MinMaxScalersklearn.preprocessing.StandardScalersklearn.preprocessing.RobustScaler