tslearn.datasets
.CachedDatasets¶
- class tslearn.datasets.CachedDatasets[source]¶
A convenience class to access cached time series datasets.
Note, that these cached datasets are statically included into tslearn and are distinct from the ones in
UCR_UEA_datasets
.When using the Trace dataset, please cite [1].
See also
UCR_UEA_datasets
Provides more datasets and supports caching.
References
[1]A. Bagnall, J. Lines, W. Vickers and E. Keogh, The UEA & UCR Time Series Classification Repository, www.timeseriesclassification.com
Methods
List cached datasets.
load_dataset
(dataset_name)Load a cached dataset from its name.
- list_datasets()[source]¶
List cached datasets.
- Returns:
- list of str:
A list of names of all cached (univariate and multivariate) dataset namas.
Examples
>>> from tslearn.datasets import UCR_UEA_datasets >>> _ = UCR_UEA_datasets().load_dataset("Trace") >>> cached = UCR_UEA_datasets().list_cached_datasets() >>> "Trace" in cached True
- load_dataset(dataset_name)[source]¶
Load a cached dataset from its name.
- Parameters:
- dataset_namestr
Name of the dataset. Should be in the list returned by
list_datasets()
.
- Returns:
- numpy.ndarray of shape (n_ts_train, sz, d) or None
Training time series. None if unsuccessful.
- numpy.ndarray of integers with shape (n_ts_train, ) or None
Training labels. None if unsuccessful.
- numpy.ndarray of shape (n_ts_test, sz, d) or None
Test time series. None if unsuccessful.
- numpy.ndarray of integers with shape (n_ts_test, ) or None
Test labels. None if unsuccessful.
- Raises:
- IOError
If the dataset does not exist or cannot be read.
Examples
>>> data_loader = CachedDatasets() >>> X_train, y_train, X_test, y_test = data_loader.load_dataset( ... "Trace") >>> print(X_train.shape) (100, 275, 1) >>> print(y_train.shape) (100,)
Examples using tslearn.datasets.CachedDatasets
¶
Hyper-parameter tuning of a Pipeline with KNeighborsTimeSeriesClassifier
Aligning discovered shapelets with timeseries
Learning Shapelets: decision boundaries in 2D distance space
Soft-DTW loss for PyTorch neural network