mojolearn.MaxAbsScaler#
- class mojolearn.MaxAbsScaler(*, copy=True)#
Scale each feature by its maximum absolute value.
Follows scikit-learn’s
MaxAbsScaler: each column is divided by the largest absolute value among its non-NaN entries, so the result lies in[-1, 1]. NaN values are kept as NaN by transform. A column of zeros is scaled by one. Input and output are float32.- Parameters:
copy (bool, default True) – Accepted for scikit-learn compatibility; transform always returns a new array.
- Variables:
max_abs_ (array of shape (n_features,)) – Per-column maximum absolute value.
scale_ (array of shape (n_features,)) – Per-column divisor (
max_abs_, with zeros replaced by one).n_features_in_ (int) – Number of columns seen in fit.
n_samples_seen_ (int) – Number of rows seen in fit.
numeric_mode_ (str) – Numeric mode the estimator was fitted in; transform runs in the same mode.
Examples
>>> import numpy as np, mojolearn >>> X = np.random.default_rng(0).standard_normal((1000, 8)).astype(np.float32) >>> Xt = mojolearn.MaxAbsScaler().fit_transform(X)
Methods
fit(X[, y])fit_transform(X[, y])Fit to
X, then transformX.get_params([deep])Return the constructor parameters as a dict.
set_params(**params)Set constructor parameters.
transform(X)- fit_transform(X, y=None, **fit_params)#
Fit to
X, then transformX.- Returns:
array – The transformed data.
- get_params(deep=True)#
Return the constructor parameters as a dict.
- Parameters:
deep (bool, default True) – Accepted for scikit-learn compatibility.
- Returns:
dict – Parameter names mapped to their values.
- set_params(**params)#
Set constructor parameters.
An unknown parameter name raises
ValueError.- Returns:
self