class pyts.preprocessing.RobustScaler(with_centering=True, with_scaling=True, quantile_range=(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.

with_centering : bool (default = True)

If True, center the data before scaling.

with_scaling : bool (default = True)

If True, scale the data to interquartile range.

quantile_range : tuple (q_min, q_max), 0.0 < q_min < q_max < 100.0

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


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


__init__(self[, with_centering, …]) Initialize self.
fit(self[, X, y]) Pass.
fit_transform(self, X[, y]) Fit to data, then transform it.
get_params(self[, deep]) Get parameters for this estimator.
set_params(self, \*\*params) Set the parameters of this estimator.
transform(self, X) Scale the data.
__init__(self, with_centering=True, with_scaling=True, quantile_range=(25.0, 75.0))[source]

Initialize self. See help(type(self)) for accurate signature.

fit(self, X=None, y=None)[source]






self : object
fit_transform(self, X, y=None, **fit_params)

Fit to data, then transform it.

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

X : numpy array of shape [n_samples, n_features]

Training set.

y : numpy array of shape [n_samples]

Target values.

**fit_params : dict

Additional fit parameters.

X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.

get_params(self, deep=True)

Get parameters for this estimator.

deep : bool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

params : mapping of string to any

Parameter names mapped to their values.

set_params(self, **params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

**params : dict

Estimator parameters.

self : object

Estimator instance.

transform(self, X)[source]

Scale the data.

X : array-like, shape = (n_samples, n_timestamps)

Data to scale.

X_new : array-like, shape = (n_samples, n_timestamps)

Scaled data.

Examples using pyts.preprocessing.RobustScaler