Skip to main content

A Captum wrapper for Time Series XAI

Project description

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},
}

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

tscaptum-0.0.6.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

tscaptum-0.0.6-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file tscaptum-0.0.6.tar.gz.

File metadata

  • Download URL: tscaptum-0.0.6.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for tscaptum-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ba0f043392f214cdf7dda2dd069c86f69ee8717d7bdd5fb80d23586983f76e29
MD5 736ac574d1dba0c84b56af7388537dcf
BLAKE2b-256 ec4ac0f85ccaa9c40efca4c8e63cbc34062c909f53c4c5f50d8fffd549f06cdb

See more details on using hashes here.

File details

Details for the file tscaptum-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: tscaptum-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for tscaptum-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8baa217b7bee32c6c3c809bfeda80ee6e8e83e6364742744a788a89513dd742c
MD5 a61008dde2faa2d50435252cc1740845
BLAKE2b-256 6976422c2c6e81ccb3d6eb3898eb690be50719700f930765c1f3ebaf75037aa2

See more details on using hashes here.

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