tslearn.preprocessing.TimeSeriesScalerMinMax

class tslearn.preprocessing.TimeSeriesScalerMinMax(value_range=(0.0, 1.0))[source]

Scaler for time series. Scales time series so that their span in each dimension is between min and max where value_range=(min, max).

Parameters:
value_range : tuple (default: (0., 1.))

The minimum and maximum value for the output time series.

Notes

This method requires a dataset of equal-sized time series.

NaNs within a time series are ignored when calculating min and max.

Examples

>>> TimeSeriesScalerMinMax(value_range=(1., 2.)).fit_transform([[0, 3, 6]])
array([[[1. ],
        [1.5],
        [2. ]]])
>>> TimeSeriesScalerMinMax(value_range=(1., 2.)).fit_transform(
...     [[numpy.nan, 3, 6]]
... )
array([[[nan],
        [ 1.],
        [ 2.]]])

Methods

fit(self, X[, y]) A dummy method such that it complies to the sklearn requirements.
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[, y]) Will normalize (min-max) each of the timeseries.
fit(self, X, y=None, **kwargs)[source]

A dummy method such that it complies to the sklearn requirements. Since this method is completely stateless, it just returns itself.

Parameters:
X

Ignored

Returns:
self
fit_transform(self, X, y=None, **kwargs)[source]

Fit to data, then transform it.

Parameters:
X : array-like of shape (n_ts, sz, d)

Time series dataset to be rescaled.

Returns:
numpy.ndarray

Resampled time series dataset.

get_params(self, deep=True)[source]

Get parameters for this estimator.

Parameters:
deep : bool, default=True

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

Returns:
params : mapping of string to any

Parameter names mapped to their values.

set_params(self, **params)[source]

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.

Parameters:
**params : dict

Estimator parameters.

Returns:
self : object

Estimator instance.

transform(self, X, y=None, **kwargs)[source]

Will normalize (min-max) each of the timeseries. IMPORTANT: this transformation is completely stateless, and is applied to each of the timeseries individually.

Parameters:
X : array-like of shape (n_ts, sz, d)

Time series dataset to be rescaled.

Returns:
numpy.ndarray

Rescaled time series dataset.