QuantileTransformer#

class pyts.preprocessing.QuantileTransformer(n_quantiles: int = 1000, output_distribution: Literal['uniform', 'normal'] = 'uniform', subsample: int = 100000, random_state: int | RandomState | None = None)[source]#

Transform samples using quantiles information.

This method transforms the samples to follow a uniform or a normal distribution. Therefore, for a given sample, 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 sample independently.

The cumulative distribution function of a feature is used to project the original values. Note that this transform is non-linear.

Parameters:
n_quantilesint, optional (default = 1000)

Number of quantiles to be computed. It corresponds to the number of landmarks used to discretize the cumulative distribution function.

output_distribution‘uniform’ or ‘normal’ (default = ‘uniform’)

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

subsampleint, optional (default = 1e5)

Maximum number of timestamps used to estimate the quantiles for computational efficiency.

random_stateint, RandomState instance or None, optional (default=None)

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random. Note that this is used by subsampling and smoothing noise.

Examples

>>> from pyts.datasets import load_gunpoint
>>> from pyts.preprocessing import QuantileTransformer
>>> X, _, _, _  = load_gunpoint(return_X_y=True)
>>> qt = QuantileTransformer(n_quantiles=10)
>>> qt.transform(X).shape
(50, 150)

Methods

__init__([n_quantiles, output_distribution, ...])

fit([X, y])

Pass.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Transform the data.

__init__(n_quantiles: int = 1000, output_distribution: Literal['uniform', 'normal'] = 'uniform', subsample: int = 100000, random_state: int | RandomState | None = None) → None[source]#
fit(X: ArrayLike | None = None, y: ArrayLike | None = None) → Self[source]#

Pass.

Parameters:
X

Ignored

y

Ignored

Returns:
selfobject
transform(X: ArrayLike) → NDArray[float64][source]#

Transform the data.

Parameters:
Xarray-like, shape = (n_samples, n_timestamps)

Data to transform.

Returns:
X_newarray-like, shape = (n_samples, n_timestamps)

Transformed data.

Examples using pyts.preprocessing.QuantileTransformer#

Transformers

Transformers