Datasets

tsseg ships a small collection of curated datasets used in the test suite and benchmarks, plus helpers to load your own data through the unified (X, y) interface.

Built-in datasets

Each loader returns a tuple (X, y):

  • X — a 2-D array of shape (n_timepoints, n_channels)

  • y — an integer array of state labels aligned with X

Example:

from tsseg.data.datasets import load_mocap

X, y = load_mocap(trial=0)
print(X.shape, y.shape)

When a dataset ships with annotated change points, you can convert dense labels into change-point indices via tsseg.algorithms.utils.extract_cps().

Custom datasets

You can wrap your own time series as lightweight dataset objects by exposing a callable returning (X, y, metadata). For testing, reuse the synthetic fixtures in tests/algorithms/conftest.py:

from tests.algorithms.conftest import synthetic_series

series = synthetic_series()
X = series["multivariate"]["X"]
y = series["multivariate"]["y"]

For large datasets, prefer storing them in an external location and provide a lazy loader to avoid shipping them inside the package.

API reference

tsseg.data.datasets.fetch_dataset(filename, unzip=False)[source]

Downloads and caches a dataset from the remote repository using Pooch.

Parameters:
  • filename (str) – The name of the file to download (must be in the Pooch registry).

  • unzip (bool) – If True, unzips the archive and returns the path to the directory.

Returns:

path – Local path to the data file or the unzipped directory.

Return type:

str

tsseg.data.datasets.load_local_dataset(filename)[source]

Loads a small dataset included directly with the library.

Parameters:

filename (str) – The name of the file (e.g., ‘my_data.csv’) located in the data directory, including any subdirectories (e.g., ‘mocap/86_01.csv’).

Returns:

data – The loaded dataset.

Return type:

pandas.DataFrame

tsseg.data.datasets.load_mocap(trial=0, return_X_y=True)[source]

Loads a trial from the MoCap dataset and returns (X, y) arrays compatible with aeon/sklearn.

Parameters:
  • trial (int or str, default=0) – The identifier for the trial to load. - If int, it’s the index in the list of available trials. - If str, it’s the trial ID (e.g., ‘01’, ‘07’).

  • return_X_y (bool, default=True) – If True, returns (X, y) arrays. If False, returns the full DataFrame.

Returns:

  • X (np.ndarray, shape (n_timestamps, n_channels)) – The time series data (features only).

  • y (np.ndarray, shape (n_timestamps,)) – The state labels for each timestamp.