MaxAbsScaler#

class cuml.preprocessing.MaxAbsScaler(*args, **kwargs)[source]#

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.

This scaler can also be applied to sparse CSR or CSC matrices.

Parameters:
copyboolean, optional, default is True

Whether a forced copy will be triggered. If copy=False, a copy might be triggered by a conversion.

Attributes:
scale_ndarray, shape (n_features,)

Per feature relative scaling of the data.

max_abs_ndarray, shape (n_features,)

Per feature maximum absolute value.

n_samples_seen_int

The number of samples processed by the estimator. Will be reset on new calls to fit, but increments across partial_fit calls.

Methods

fit(X[, y])

Compute the maximum absolute value to be used for later scaling.

inverse_transform(X)

Scale back the data to the original representation

partial_fit(X[, y])

Online computation of max absolute value of X for later scaling.

transform(X)

Scale the data

See also

maxabs_scale

Equivalent function without the estimator API.

Notes

NaNs are treated as missing values: disregarded in fit, and maintained in transform.

Examples

>>> from cuml.preprocessing import MaxAbsScaler
>>> import cupy as cp
>>> X = [[ 1., -1.,  2.],
...      [ 2.,  0.,  0.],
...      [ 0.,  1., -1.]]
>>> X = cp.array(X)
>>> transformer = MaxAbsScaler().fit(X)
>>> transformer
MaxAbsScaler()
>>> transformer.transform(X)
array([[ 0.5, -1. ,  1. ],
       [ 1. ,  0. ,  0. ],
       [ 0. ,  1. , -0.5]])
fit(X, y=None) MaxAbsScaler[source]#

Compute the maximum absolute value to be used for later scaling.

Parameters:
X{array-like, sparse matrix}, shape [n_samples, n_features]

The data used to compute the per-feature minimum and maximum used for later scaling along the features axis.

inverse_transform(X) SparseCumlArray[source]#

Scale back the data to the original representation

Parameters:
X{array-like, sparse matrix}

The data that should be transformed back.

partial_fit(X, y=None) MaxAbsScaler[source]#

Online computation of max absolute value of X for later scaling.

All of X is processed as a single batch. This is intended for cases when fit() is not feasible due to very large number of n_samples or because X is read from a continuous stream.

Parameters:
X{array-like, sparse matrix}, shape [n_samples, n_features]

The data used to compute the mean and standard deviation used for later scaling along the features axis.

yNone

Ignored.

Returns:
selfobject

Transformer instance.

transform(X) SparseCumlArray[source]#

Scale the data

Parameters:
X{array-like, sparse matrix}

The data that should be scaled.