Skip to main content

Generate synthetic time series with known ground truth feature locations for XAI evaluation

Project description

DOI

xaitimesynth

A Python package for benchmarking explainable AI (XAI) algorithms (mostly feature attributions) on time series classification tasks using synthetic data with known ground truth feature locations.

Why xaitimesynth?

Evaluating XAI methods for time series is challenging because we rarely know which time points truly matter for classification. xaitimesynth solves this by generating synthetic data where you control exactly where the class-discriminating features are located.

Each synthetic time series follows a simple additive model: x = background + feature, where the feature is placed at a known window. This lets you directly measure whether attribution methods correctly identify the important time points.

Key Features

  • Known ground truth: Feature locations are tracked internally, enabling direct evaluation of attribution correctness
  • Flexible data generation: Combine signals (random walks, seasonal patterns, noise) with localized features (peaks, level shifts, pulses)
  • Univariate and multivariate: Generate single-channel or multi-channel time series
  • Fluent builder API: Chain methods to define complex datasets concisely
  • YAML configuration: Define datasets in config files for reproducibility
  • Built-in metrics: AUC-PR, AUC-ROC, Relevance Mass Accuracy, Relevance Rank Accuracy, and more

Installation

pip install xaitimesynth

Quick Start

from xaitimesynth import TimeSeriesBuilder, gaussian_noise, gaussian_pulse, seasonal
from xaitimesynth.metrics import auc_pr_score, relevance_mass_accuracy
import numpy as np

# define dataset structure once
base_builder = (
    TimeSeriesBuilder(n_timesteps=100, normalization="zscore")
    .for_class(0)
    .add_signal(gaussian_noise(sigma=1.0))
    .add_feature(gaussian_pulse(amplitude=3.0), random_location=True, length_pct=0.3)
    .for_class(1)
    .add_signal(gaussian_noise(sigma=1.0))
    .add_feature(
        seasonal(period=10, amplitude=3.0), random_location=True, length_pct=0.3
    )
)

# generate train and test sets with different seeds
train = base_builder.clone(n_samples=200, random_state=42).build()
test = base_builder.clone(n_samples=50, random_state=43).build()

# visualise instances from created dataset (by default first observation from each class)
plot = plot_components(train)
plot.show()

# Replace with your XAI method output; shape must be (n_samples, n_dims, n_timesteps)
attributions = np.random.rand(*test["X"].shape)

# Evaluate against ground truth feature locations
auc = auc_pr_score(attributions, test, normalize=True)
rma = relevance_mass_accuracy(attributions, test)

Example plot

Documentation

Full documentation is available at gregorbaer.github.io/xaitimesynth.

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

Citation

If you use xaitimesynth in your work, please consider citing:

Baer, G. (2026). xaitimesynth: A Python Package for Evaluating Attribution Methods for Time Series with Synthetic Ground Truth (arXiv:2603.06781). arXiv. https://doi.org/10.48550/arXiv.2603.06781

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xaitimesynth-0.1.1.tar.gz (200.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xaitimesynth-0.1.1-py3-none-any.whl (59.2 kB view details)

Uploaded Python 3

File details

Details for the file xaitimesynth-0.1.1.tar.gz.

File metadata

  • Download URL: xaitimesynth-0.1.1.tar.gz
  • Upload date:
  • Size: 200.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xaitimesynth-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e3bfdf16f1acca36b3ab511b1a5b0c3b948e06553b64ffcf63af222c56fd8e3a
MD5 a78d48b5f1a764c4168cbc759449b01d
BLAKE2b-256 631f1994dd0cdd096b272463dd21a62abd01ac25683e3e73b99376e39df35121

See more details on using hashes here.

Provenance

The following attestation bundles were made for xaitimesynth-0.1.1.tar.gz:

Publisher: publish.yml on gregorbaer/xaitimesynth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xaitimesynth-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: xaitimesynth-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 59.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xaitimesynth-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21218d71eb8aa79e839860615907062a65828c7677463d9f5057dc0f14a62621
MD5 04e806b5fddf7123b9b57b9b6f23fe78
BLAKE2b-256 eafc200bb21496f1d0a3ac006a0be73efad88ed6336d5979fe9a9ef215c0e160

See more details on using hashes here.

Provenance

The following attestation bundles were made for xaitimesynth-0.1.1-py3-none-any.whl:

Publisher: publish.yml on gregorbaer/xaitimesynth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page