# QuantileTransformer

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

Transform features using quantiles information.

This method transforms the features to follow a uniform or a normal
distribution. Therefore, for a given feature, this transformation tends
to spread out the most frequent values. It also reduces the impact of
(marginal) outliers: this is therefore a robust preprocessing scheme.

The transformation is applied on each feature independently. First an
estimate of the cumulative distribution function of a feature is
used to map the original values to a uniform distribution. The obtained
values are then mapped to the desired output distribution using the
associated quantile function. Features values of new/unseen data that fall
below or above the fitted range will be mapped to the bounds of the output
distribution. Note that this transform is non-linear. It may distort linear
correlations between variables measured at the same scale but renders
variables measured at different scales more directly comparable.

* **Parameters:**
  **n_quantiles**
  : Number of quantiles to be computed. It corresponds to the number
    of landmarks used to discretize the cumulative distribution function.
    <br/>
    #### Versionchanged
    Changed in version 26.12: `n_quantiles` is no longer capped at the number of samples.

  **output_distribution**
  : Marginal distribution for the transformed data. The choices are
    ‘uniform’ (default) or ‘normal’.

  **ignore_implicit_zeros**
  : Only applies to sparse matrices. If True, the sparse entries of the
    matrix are discarded to compute the quantile statistics. If False,
    these entries are treated as zeros.

  **subsample**
  : Maximum number of samples used to estimate the quantiles for
    computational efficiency. Note that the subsampling procedure may
    differ for value-identical sparse and dense matrices.
    Disable subsampling by setting `subsample=None`.
    <br/>
    #### Deprecated
    Deprecated since version 26.12: The default value of `subsample` will change from 100_000 to
    10_000 in 27.02 to match scikit-learn.

  **random_state**
  : Determines random number generation for subsampling and smoothing
    noise.
    Please see `subsample` for more details.
    Pass an int for reproducible results across multiple function calls.
    See [Glossary](https://scikit-learn.org/stable/glossary.html#term-random_state)

  **copy**
  : Set to False to perform inplace transformation and avoid a copy (if the
    input is already a numpy array).
* **Attributes:**
  **n_quantiles_**
  : The number of quantiles used to discretize the cumulative
    distribution function. Always equal to `n_quantiles`.

  **quantiles_**
  : The values corresponding the quantiles of reference.

  **references_**
  : Quantiles of references.

### Methods

| [`fit`](#cuml.preprocessing.QuantileTransformer.fit)(X[, y])          | Compute the quantiles used for transforming.   |
|-----------------------------------------------------------------------|------------------------------------------------|
| [`inverse_transform`](#cuml.preprocessing.QuantileTransformer.inverse_transform)(X) | Back-projection to the original space.         |
| [`transform`](#cuml.preprocessing.QuantileTransformer.transform)(X)         | Feature-wise transformation of the data.       |

#### SEE ALSO
`quantile_transform`
: Equivalent function without the estimator API.

[`PowerTransformer`](../cuml.preprocessing.PowerTransformer/index.html.md#cuml.preprocessing.PowerTransformer)
: Perform mapping to a normal distribution using a power transform.

[`StandardScaler`](../cuml.preprocessing.StandardScaler/index.html.md#cuml.preprocessing.StandardScaler)
: Perform standardization that is faster, but less robust to outliers.

[`RobustScaler`](../cuml.preprocessing.RobustScaler/index.html.md#cuml.preprocessing.RobustScaler)
: Perform robust standardization that removes the influence of outliers but does not put outliers and inliers on the same scale.

### Notes

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

### Examples

```pycon
>>> import cupy as cp
>>> from cuml.preprocessing import QuantileTransformer
>>> rng = cp.random.RandomState(0)
>>> X = cp.sort(rng.normal(loc=0.5, scale=0.25, size=(25, 1)), axis=0)
>>> qt = QuantileTransformer(n_quantiles=10, random_state=0)
>>> qt.fit_transform(X)
array([...])
```

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

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

Compute the quantiles used for transforming.

* **Parameters:**
  **X**
  : The data used to scale along the features axis. If a sparse
    matrix is provided, it will be converted into a sparse
    `csc_matrix`. Additionally, the sparse matrix needs to be
    nonnegative if `ignore_implicit_zeros` is False.
* **Returns:**
  **self**

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

Back-projection to the original space.

* **Parameters:**
  **X**
  : The data used to scale along the features axis. If a sparse
    matrix is provided, it will be converted into a sparse
    `csc_matrix`. Additionally, the sparse matrix needs to be
    nonnegative if `ignore_implicit_zeros` is False.
* **Returns:**
  **Xt**
  : The projected data.

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

Feature-wise transformation of the data.

* **Parameters:**
  **X**
  : The data used to scale along the features axis. If a sparse
    matrix is provided, it will be converted into a sparse
    `csc_matrix`. Additionally, the sparse matrix needs to be
    nonnegative if `ignore_implicit_zeros` is False.
* **Returns:**
  **Xt**
  : The projected data.

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