# RobustScaler

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

Scale features using statistics that are robust to outliers.

This Scaler removes the median and scales the data according to the
quantile range (defaults to IQR: Interquartile Range). The IQR is the range
between the 1st quartile (25th quantile) and the 3rd quartile (75th
quantile).

Centering and scaling happen independently on each feature by computing the
relevant statistics on the samples in the training set. Median and
interquartile range are then stored to be used on later data using the
`transform` method.

Standardization of a dataset is a common requirement for many machine
learning estimators. Typically this is done by removing the mean and
scaling to unit variance. However, outliers can often influence the sample
mean / variance in a negative way. In such cases, the median and the
interquartile range often give better results.

* **Parameters:**
  **with_centering**
  : If True, center the data before scaling.
    This will cause `transform` to raise an exception when attempted on
    sparse matrices, because centering them entails building a dense
    matrix which in common use cases is likely to be too large to fit in
    memory.

  **with_scaling**
  : If True, scale the data to interquartile range.

  **quantile_range**
  : Default: (25.0, 75.0) = (1st quantile, 3rd quantile) = IQR
    Quantile range used to calculate `scale_`.

  **copy**
  : Whether a forced copy will be triggered. If copy=False, a copy might
    be triggered by a conversion.
* **Attributes:**
  **center_**
  : The median value for each feature in the training set.

  **scale_**
  : The (scaled) interquartile range for each feature in the training set.

### Methods

| [`fit`](#cuml.preprocessing.RobustScaler.fit)(X[, y])          | Compute the median and quantiles to be used for scaling.   |
|-----------------------------------------------------------------------|------------------------------------------------------------|
| [`inverse_transform`](#cuml.preprocessing.RobustScaler.inverse_transform)(X) | Scale back the data to the original representation         |
| [`transform`](#cuml.preprocessing.RobustScaler.transform)(X)         | Center and scale the data.                                 |

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

[`cuml.decomposition.PCA`](../cuml.decomposition.PCA/index.html.md#cuml.decomposition.PCA)
: Further removes the linear correlation across features with `whiten=True`.

### Examples

```pycon
>>> from cuml.preprocessing import RobustScaler
>>> import cupy as cp
>>> X = [[ 1., -2.,  2.],
...      [ -2.,  1.,  3.],
...      [ 4.,  1., -2.]]
>>> X = cp.array(X)
>>> transformer = RobustScaler().fit(X)
>>> transformer
RobustScaler()
>>> transformer.transform(X)
array([[ 0. , -2. ,  0. ],
       [-1. ,  0. ,  0.4],
       [ 1. ,  0. , -1.6]])
```

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

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

Compute the median and quantiles to be used for scaling.

* **Parameters:**
  **X**
  : The data used to compute the median and quantiles
    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#L1400)

Scale back the data to the original representation

* **Parameters:**
  **X**
  : The data used to scale along the specified axis.

<!-- !! 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#L1371)

Center and scale the data.

* **Parameters:**
  **X**
  : The data used to scale along the specified axis.

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