TSInterpret

TSInterpret: A Python Package for the Interpretability of Time Series Classification - Published in JOSS (2023)

https://github.com/fzi-forschungszentrum-informatik/tsinterpret

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: arxiv.org, joss.theoj.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

counterfactual-explanations explainable-ai explainable-artificial-intelligence explainable-ml feature-attribution interpretability interpretable-machine-learning interpretable-ml time-series

Keywords from Contributors

standardization

Scientific Fields

Sociology Social Sciences - 40% confidence
Engineering Computer Science - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

An Open-Source Library for the interpretability of time series classifiers

Basic Info
  • Host: GitHub
  • Owner: fzi-forschungszentrum-informatik
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 200 MB
Statistics
  • Stars: 139
  • Watchers: 3
  • Forks: 15
  • Open Issues: 4
  • Releases: 33
Topics
counterfactual-explanations explainable-ai explainable-artificial-intelligence explainable-ml feature-attribution interpretability interpretable-machine-learning interpretable-ml time-series
Created over 3 years ago · Last pushed about 1 year ago
Metadata Files
Readme Contributing License Zenodo

README.md

TSInterpret Logo

tests PyPI PyPI - Downloads GitHub DOI badge

TSInterpret is a Python library for interpreting time series classification. The ambition is to faciliate the usage of time series interpretability methods. The Framework supports Sklearn, Tensorflow, Torch and in some cases predict functions. A listing of implemented algorithms and supported frameworks can be found in our Documentation. More information on our framework can be found in our paper.

💈 Installation

shell pip install TSInterpret You can install the latest development version from GitHub as so: shell pip install https://github.com/fzi-forschungszentrum-informatik/TSInterpret/archive/refs/heads/main.zip

🍫 Quickstart

The following example creates a simple Neural Network based on tensorflow and interprets the Classfier with Integrated Gradients and Temporal Saliency Rescaling [1]. For further examples check out the Documentation.

[1] Ismail, Aya Abdelsalam, et al. "Benchmarking deep learning interpretability in time series predictions." Advances in neural information processing systems 33 (2020): 6441-6452.

Import

```python import pickle import numpy as np import matplotlib.pyplot as plt import seaborn as snst from tslearn.datasets import UCRUEAdatasets import tensorflow as tf

```

Create Classifcation Model

This Section uses a pretrained Classification Model to illustrate the use of our package. For running the example, please clone our repository and comment the variable PATHTOYOURCLASSIFICATIONMODEL in. The code in this section can also be replaces with your personal classification model written in torch or tensorflow. ```python

Load data.

dataset='BasicMotions' trainx,trainy, testx, testy=UCRUEAdatasets().loaddataset(dataset) enc1=sklearn.OneHotEncoder(sparse=False).fit(trainy.reshape(-1,1)) trainy=enc1.transform(trainy.reshape(-1,1)) testy=enc1.transform(testy.reshape(-1,1))

Load a model.

e.g., PATHTOYOURCLASSIFICATIONMODEL=f'./TSInterpret/ClassificationModels/models/{dataset}/cnn/{dataset}best_model.hdf5'

modeltoexplain = tf.keras.models.loadmodel(PATHTOYOURCLASSIFICATION_MODEL)

```

Explain & Visualize Model

```python from TSInterpret.InterpretabilityModels.Saliency.TSR import TSR intmod=TSR(modeltoexplain, trainx.shape[-2],trainx.shape[-1], method='IG',mode='time') item= np.array([testx[0,:,:]]) label=int(np.argmax(test_y[0]))

exp=int_mod.explain(item,labels=label,TSR =True)

%matplotlib inline
intmod.plot(np.array([testx[0,:,:]]),exp)

```

Algorithm Results

:monocle_face: Why a special package for the interpretability of time series predictors?

Compared to other data types like tabular, image, or natural language data, time series data is unintuitive to understand. Approaches to the explainability of tabular regression and classification often assume independent features. Compared to images or textual data, humans cannot intuitively and instinctively understand the underlying information contained in time series data. Further, research has shown that applying explainability algorithms for tabular, image, or natural language data often yields non-understandable and inaccurate explanations, as they do not consider the time component (e.g., highlighting many unconnected time-steps, instead of features or time slices [1]). Increasing research has focused on developing and adapting approaches to time series (survey: [2]). However, with no unified interface, accessibility to those methods is still an issue. TSInterpret tries to facilitate this by providing a PyPI package with a unified interface for multiple algorithms, documentation, and learning resources (notebooks) on the application.

[2] Rojat, Thomas, et al. "Explainable artificial intelligence (xai) on timeseries data: A survey." arXiv preprint arXiv:2104.00950 (2021).

👐 Contributing

Feel free to contribute in any way you like, we're always open to new ideas and approaches.

  • If you have questions, spotted a bug or ideas, feel free to open an issue.
  • Before opening a pull request, we also encourage users to open an issue for discussion.

Details on how to Contribute can be found here.

🏫 Affiliations

FZI Logo

Citation

If you use TSInterpret in your research, please consider citing it and the authors' original papers. The authors' original papers are cited in the documentation and the paper below.

@article{Höllig2023, doi = {10.21105/joss.05220}, url = {https://doi.org/10.21105/joss.05220}, year = {2023}, publisher = {The Open Journal}, volume = {8}, number = {85}, pages = {5220}, author = {Jacqueline Höllig and Cedric Kulbach and Steffen Thoma}, title = {TSInterpret: A Python Package for the Interpretability of Time Series Classification}, journal = {Journal of Open Source Software} }

Owner

  • Name: FZI Forschungszentrum Informatik
  • Login: fzi-forschungszentrum-informatik
  • Kind: organization
  • Email: github@fzi.de
  • Location: Karlsruhe, Germany

FZI Research Center for Information Technology

JOSS Publication

TSInterpret: A Python Package for the Interpretability of Time Series Classification
Published
May 05, 2023
Volume 8, Issue 85, Page 5220
Authors
Jacqueline Höllig ORCID
FZI Research Center for Information Technology, Karlsruhe, Germany
Cedric Kulbach ORCID
FZI Research Center for Information Technology, Karlsruhe, Germany
Steffen Thoma ORCID
FZI Research Center for Information Technology, Karlsruhe, Germany
Editor
Britta Westner ORCID

GitHub Events

Total
  • Create event: 2
  • Release event: 1
  • Issues event: 2
  • Watch event: 18
  • Delete event: 1
  • Issue comment event: 3
  • Push event: 4
  • Pull request event: 4
  • Fork event: 6
Last Year
  • Create event: 2
  • Release event: 1
  • Issues event: 2
  • Watch event: 18
  • Delete event: 1
  • Issue comment event: 3
  • Push event: 4
  • Pull request event: 4
  • Fork event: 6

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 445
  • Total Committers: 9
  • Avg Commits per committer: 49.444
  • Development Distribution Score (DDS): 0.103
Past Year
  • Commits: 34
  • Committers: 2
  • Avg Commits per committer: 17.0
  • Development Distribution Score (DDS): 0.029
Top Committers
Name Email Commits
Jacqueline Hoellig h****g@f****e 399
Cedric Kulbach 4****c 21
Bela 6****7 9
kulbach k****h@f****e 6
github-actions[bot] 4****] 3
Cedric Kulbach c****c@g****m 3
Britta Westner b****r@g****m 2
Durande KAMGA 5****x 1
Rishabh Agrahari r****i@t****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 38
  • Total pull requests: 34
  • Average time to close issues: 28 days
  • Average time to close pull requests: about 6 hours
  • Total issue authors: 18
  • Total pull request authors: 7
  • Average comments per issue: 2.53
  • Average comments per pull request: 0.41
  • Merged pull requests: 27
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 3
  • Average time to close issues: 1 day
  • Average time to close pull requests: about 8 hours
  • Issue authors: 2
  • Pull request authors: 3
  • Average comments per issue: 3.0
  • Average comments per pull request: 0.67
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ulf1 (6)
  • LbzSteven (5)
  • hugo-rddi (5)
  • JHoelli (3)
  • HaoWenJohn (2)
  • shrezaei (2)
  • JanaSw (2)
  • R-Z78 (2)
  • marreapato (2)
  • hfakih96 (1)
  • madarax64 (1)
  • john2choi (1)
  • AlexisTabin (1)
  • niruc100 (1)
  • alitirmizi23 (1)
Pull Request Authors
  • JHoelli (28)
  • belaboe97 (4)
  • kndbvortex (2)
  • james-sexton96 (1)
  • britta-wstnr (1)
  • kulbachcedric (1)
  • pyaf (1)
Top Labels
Issue Labels
bug (3) enhancement (1)
Pull Request Labels

Dependencies

Pipfile pypi
  • ipykernel * develop
Pipfile.lock pypi
  • backcall ==0.2.0 develop
  • debugpy ==1.6.3 develop
  • decorator ==5.1.1 develop
  • entrypoints ==0.4 develop
  • ipykernel ==6.16.2 develop
  • ipython ==7.34.0 develop
  • jedi ==0.18.1 develop
  • jupyter-client ==7.4.4 develop
  • jupyter-core ==4.11.2 develop
  • matplotlib-inline ==0.1.6 develop
  • nest-asyncio ==1.5.6 develop
  • packaging ==21.3 develop
  • parso ==0.8.3 develop
  • pexpect ==4.8.0 develop
  • pickleshare ==0.7.5 develop
  • prompt-toolkit ==3.0.31 develop
  • psutil ==5.9.3 develop
  • ptyprocess ==0.7.0 develop
  • pygments ==2.13.0 develop
  • pyparsing ==3.0.9 develop
  • python-dateutil ==2.8.2 develop
  • pyzmq ==24.0.1 develop
  • setuptools ==65.5.0 develop
  • six ==1.16.0 develop
  • tornado ==6.2 develop
  • traitlets ==5.5.0 develop
  • wcwidth ==0.2.5 develop
.github/workflows/mkdocs.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/python-publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
.github/workflows/unit-tests.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v3 composite
.github/workflows/cla.yml actions
  • contributor-assistant/github-action v2.3.0 composite
setup.py pypi