RobustScaler#

class pyts.preprocessing.RobustScaler(with_centering: bool = True, with_scaling: bool = True, quantile_range: tuple[float, float] = (25.0, 75.0))[source]#

Scale samples 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 sample by computing the relevant statistics on the timestamps. Median and interquartile range are used to transform the data.

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_centeringbool (default = True)

If True, center the data before scaling.

with_scalingbool (default = True)

If True, scale the data to interquartile range.

quantile_rangetuple (q_min, q_max), 0.0 < q_min < q_max < 100.0

Default: (25.0, 75.0) = (1st quantile, 3rd quantile) = IQR

Examples

>>> from pyts.preprocessing import RobustScaler
>>> X = [[1, -2,  4],
...      [-2,  1,  1],
...      [2,  3, -2]]
>>> scaler = RobustScaler()
>>> scaler.transform(X)
array([[ 0. , -1. ,  1. ],
       [-2. ,  0. ,  0. ],
       [ 0. ,  0.4, -1.6]])

Methods

__init__([with_centering, with_scaling, ...])

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_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Scale the data.

__init__(with_centering: bool = True, with_scaling: bool = True, quantile_range: tuple[float, float] = (25.0, 75.0)) → 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]#

Scale the data.

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

Data to scale.

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

Scaled data.

Examples using pyts.preprocessing.RobustScaler#

Scalers

Scalers