# MaxAbsScaler

### *class* cuml.preprocessing.MaxAbsScaler(\*args, \*\*kwargs)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/_thirdparty/sklearn/preprocessing/_data.py#L952)

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:**
  **copy**
  : Whether a forced copy will be triggered. If copy=False, a copy might
    be triggered by a conversion.
* **Attributes:**
  **scale_**
  : Per feature relative scaling of the data.

  **max_abs_**
  : Per feature maximum absolute value.

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

### Methods

| [`fit`](#cuml.preprocessing.MaxAbsScaler.fit)(X[, y])          | Compute the maximum absolute value to be used for later scaling.   |
|-----------------------------------------------------------------------|--------------------------------------------------------------------|
| [`inverse_transform`](#cuml.preprocessing.MaxAbsScaler.inverse_transform)(X) | Scale back the data to the original representation                 |
| [`partial_fit`](#cuml.preprocessing.MaxAbsScaler.partial_fit)(X[, y])  | Online computation of max absolute value of X for later scaling.   |
| [`transform`](#cuml.preprocessing.MaxAbsScaler.transform)(X)         | Scale the data                                                     |

#### SEE ALSO
[`maxabs_scale`](../cuml.preprocessing.maxabs_scale/index.html.md#cuml.preprocessing.maxabs_scale)
: Equivalent function without the estimator API.

### Notes

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

### Examples

```pycon
>>> 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]])
```

<!-- !! processed by numpydoc !! -->

#### fit(X, y=None) → [MaxAbsScaler](#cuml.preprocessing.MaxAbsScaler)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/_thirdparty/sklearn/preprocessing/_data.py#L1038)

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

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

<!-- !! processed by numpydoc !! -->

#### fit_transform(X, y=None, \*\*fit_params)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/_thirdparty/sklearn/utils/skl_dependencies.py#L42)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params
and returns a transformed version of X.

* **Parameters:**
  **X**

  **y**
  : Target values.

  **\*\*fit_params**
  : Additional fit parameters.
* **Returns:**
  **X_new**
  : Transformed array.

<!-- !! processed by numpydoc !! -->

#### get_feature_names_out(input_features=None)

Get output feature names for transformation.

* **Parameters:**
  **input_features**
  : Input features.
    - If `input_features` is [`None`](https://docs.python.org/3/builtins/constants.html#None), then `feature_names_in_` is
      used as feature names in. If `feature_names_in_` is not defined,
      then the following input feature names are generated:
      `["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
    - If `input_features` is an array-like, then `input_features` must
      match `feature_names_in_` if `feature_names_in_` is defined.
* **Returns:**
  **feature_names_out**
  : Same as input features.

<!-- !! processed by numpydoc !! -->

#### get_params(deep=True)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/base.py#L191)

Returns a dict of all params owned by this class. If the child class
has appropriately overridden the `_get_param_names` method and does not
need anything other than what is there in this method, then it doesn’t
have to override this method

<!-- !! processed by numpydoc !! -->

#### inverse_transform(X)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/_thirdparty/sklearn/preprocessing/_data.py#L1128)

Scale back the data to the original representation

* **Parameters:**
  **X**
  : The data that should be transformed back.

<!-- !! processed by numpydoc !! -->

#### partial_fit(X, y=None) → [MaxAbsScaler](#cuml.preprocessing.MaxAbsScaler)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/_thirdparty/sklearn/preprocessing/_data.py#L1053)

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()`](#cuml.preprocessing.MaxAbsScaler.fit) is not feasible due to very large number of
`n_samples` or because X is read from a continuous stream.

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

  **y**
  : Ignored.
* **Returns:**
  **self**
  : Transformer instance.

<!-- !! processed by numpydoc !! -->

#### set_params(\*\*params)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/base.py#L200)

Accepts a dict of params and updates the corresponding ones owned by
this class. If the child class has appropriately overridden the
`_get_param_names` method and does not need anything other than what is,
there in this method, then it doesn’t have to override this method

<!-- !! processed by numpydoc !! -->

#### transform(X)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/_thirdparty/sklearn/preprocessing/_data.py#L1102)

Scale the data

* **Parameters:**
  **X**
  : The data that should be scaled.

<!-- !! processed by numpydoc !! -->
