Generate synthetic time series with known ground truth feature locations for XAI evaluation
Project description
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)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3bfdf16f1acca36b3ab511b1a5b0c3b948e06553b64ffcf63af222c56fd8e3a
|
|
| MD5 |
a78d48b5f1a764c4168cbc759449b01d
|
|
| BLAKE2b-256 |
631f1994dd0cdd096b272463dd21a62abd01ac25683e3e73b99376e39df35121
|
Provenance
The following attestation bundles were made for xaitimesynth-0.1.1.tar.gz:
Publisher:
publish.yml on gregorbaer/xaitimesynth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xaitimesynth-0.1.1.tar.gz -
Subject digest:
e3bfdf16f1acca36b3ab511b1a5b0c3b948e06553b64ffcf63af222c56fd8e3a - Sigstore transparency entry: 1073444358
- Sigstore integration time:
-
Permalink:
gregorbaer/xaitimesynth@795a276a69108cf95f0285c3c913f3fe2f0d187f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/gregorbaer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@795a276a69108cf95f0285c3c913f3fe2f0d187f -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21218d71eb8aa79e839860615907062a65828c7677463d9f5057dc0f14a62621
|
|
| MD5 |
04e806b5fddf7123b9b57b9b6f23fe78
|
|
| BLAKE2b-256 |
eafc200bb21496f1d0a3ac006a0be73efad88ed6336d5979fe9a9ef215c0e160
|
Provenance
The following attestation bundles were made for xaitimesynth-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on gregorbaer/xaitimesynth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xaitimesynth-0.1.1-py3-none-any.whl -
Subject digest:
21218d71eb8aa79e839860615907062a65828c7677463d9f5057dc0f14a62621 - Sigstore transparency entry: 1073444367
- Sigstore integration time:
-
Permalink:
gregorbaer/xaitimesynth@795a276a69108cf95f0285c3c913f3fe2f0d187f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/gregorbaer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@795a276a69108cf95f0285c3c913f3fe2f0d187f -
Trigger Event:
release
-
Statement type: