Skip to main content

tsCaptum - A library for univariate and multivariate time series explanation

tsCaptum is a library that adapts the popular post-hoc attribution methods implemented in the Captum framework to work with time series. Unlike previous libraries tsCaptum is :

  1. Fully compatible with scikit-learn and popular time-series frameworks such as aeon and sktime (e.g., so it is easy to combine ROCKET with SHAP).
  2. Takes advantage of TS locality by using time series segmentation (so SHAP runs fast with long time series and suffers less from vanishing attribution weights)
  3. It's extremely easy to use requiring almost no effort by the users
from aeon.classification.convolution_based import RocketClassifier
clf = RocketClassifier(n_jobs=-1)
clf.fit(MP_X_train,MP_y_train)

from tsCaptum.explainers import Feature_Ablation
myFA = Feature_Ablation(clf)
exp = myFA.explain(samples=CMJ_X_test_samples, labels=CMJ_y_test_samples, n_segments=10, normalise=False, baseline=0)

from tsCaptum.explainers import Shapley_Value_Sampling as SHAP
mySHAP = SHAP(clf)
exp = mySHAP.explain(CMJ_X_test_samples, labels=CMJ_y_test_samples,  n_segments=10, normalise=False, baseline=0)

More examples can be found in the examples_tscaptum notebook with detailed steps for training, prediction and explanation. Some of the attribution methods available in captum have been described and quantitatively evaluated for time series explanation in our recent ECMLPKDD 2024 paper.

Installation using pip

pip install tsCaptum

In case you have problems installing torch (e.g. you use Linux as OS and you want a lighter installation) use

pip install torch --index-url https://download.pytorch.org/whl/cpu && pip install tsCaptum

Citation

In case you use this library please cite:

@misc{tsCaptum,
    author = {Davide Italo Serramazza, Thach Le Nguyen, Georgiana Ifrim},
    title = {A Short Tutorial for Multivariate Time Series Explanation using tsCaptum},
    journal = {Software Impacts},
    year = {2024},
    publisher = {Elsevier},
    note = {In Press},
    url = { https://github.com/mlgig/tscaptum},
}

Metadata

Release files for tsCaptum 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tsCaptum 0.0.7
File Size Uploaded
tscaptum-0.0.7.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tsCaptum 0.0.7
File Interpreter ABI Platform
tscaptum-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / tscaptum-0.0.7.tar.gz

Download URL tscaptum-0.0.7.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c04235cb11e94e24af8259adf4b86d03a380121d41e01c83045eca1620b29ae8
BLAKE2b-256 checksum
How to use checksums
cf42c6d26dbfb82bfcd16733ced577e853ea444198a64b8a3c5e19d0a1ea3f80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / tscaptum-0.0.7-py3-none-any.whl

Download URL tscaptum-0.0.7-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b64be2f677cebbaf28e46ed149b0ed4beecd0f8b64053a77732b0e228f634ab2
BLAKE2b-256 checksum
How to use checksums
66c7fb1c2f9721bb4f212e4dbb9599c3d7aa4ef557ecdedda553d7ab5fd330d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release history Release notifications | RSS feed

0.0.8

2 release files

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page