tslearn.utils

The tslearn.utils module includes various utilities.

Generic functions

to_time_series(ts[, remove_nans]) Transforms a time series so that it fits the format used in tslearn models.
to_time_series_dataset(dataset[, dtype]) Transforms a time series dataset so that it fits the format used in tslearn models.
to_sklearn_dataset(dataset[, dtype, return_dim]) Transforms a time series dataset so that it fits the format used in sklearn estimators.
ts_size(ts) Returns actual time series size.
ts_zeros(sz[, d]) Returns a time series made of zero values.
load_time_series_txt(fname) Loads a time series dataset from disk.
save_time_series_txt(fname, dataset[, fmt]) Writes a time series dataset to disk.
check_equal_size(dataset) Check if all time series in the dataset have the same size.
check_dims(X[, X_fit_dims, extend, …]) Reshapes X to a 3-dimensional array of X.shape[0] univariate timeseries of length X.shape[1] if X is 2-dimensional and extend is True.

Conversion functions

The following functions are provided for the sake of interoperability between standard Python packages for time series. They allow conversion between tslearn format and other libraries’ formats.

to_pyts_dataset(X) Transform a tslearn-compatible dataset into a pyts dataset.
from_pyts_dataset(X) Transform a pyts-compatible dataset into a tslearn dataset.
to_sktime_dataset(X) Transform a tslearn-compatible dataset into a sktime dataset.
from_sktime_dataset(X) Transform a sktime-compatible dataset into a tslearn dataset.
to_cesium_dataset(X) Transform a tslearn-compatible dataset into a cesium dataset.
from_cesium_dataset(X) Transform a cesium-compatible dataset into a tslearn dataset.
to_seglearn_dataset(X) Transform a tslearn-compatible dataset into a seglearn dataset.
from_seglearn_dataset(X) Transform a seglearn-compatible dataset into a tslearn dataset.
to_tsfresh_dataset(X) Transform a tslearn-compatible dataset into a tsfresh dataset.
from_tsfresh_dataset(X) Transform a tsfresh-compatible dataset into a tslearn dataset.
to_stumpy_dataset(X) Transform a tslearn-compatible dataset into a stumpy dataset.
from_stumpy_dataset(X) Transform a stumpy-compatible dataset into a tslearn dataset.
to_pyflux_dataset(X) Transform a tslearn-compatible dataset into a pyflux dataset.
from_pyflux_dataset(X) Transform a pyflux-compatible dataset into a tslearn dataset.