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)

It can be installed by typing the command "pip install tsCaptum" or in case you have problems installing torch (e.g. you use Linux as OS and you want a lighter installation) use "pip3 install torch --index-url https://download.pytorch.org/whl/cpu && pip install tsCaptum"

In case you use this library please cite:

@misc{tsCaptum,
    author = {Davide Italo Serramazza, Thach Le Nguyen, Georgiana Ifrim},
    title = {tsCaptum: adapting Captum explainers for time series and scikit-learn-like predictors},
    howpublished = {GitHub},
    year = {2024},
    note = {Temporary bibitex entry},
    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.1.tar.gz (8.1 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.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tscaptum-0.0.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.1

File hashes

Hashes for tscaptum-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1beb00f59bcf7d750e2bd65f0eeeab83f38d861b39b9dae6b75cf10ede1a5969
MD5 86d954208fd91e9981d3ec9f8c3e4fc7
BLAKE2b-256 ab950b0cde0e4fa4431d05f25b5460f31975caa33aa9af75be5b235cb40ec350

See more details on using hashes here.

File details

Details for the file tsCaptum-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tsCaptum-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.1

File hashes

Hashes for tsCaptum-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7dbe354382c4894f85c30d3e708d756c76c69f31991d9c75275931076170236f
MD5 cc3c4a0e4af2c1d9b2552105bc81c25e
BLAKE2b-256 a8496ffb2c0ccf441ba8476ca599c9ce133cafed28fc7047e9e43feae7c27ab0

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