todo
Project description
TSInterpret is a Python library for interpreting time series classification. The ambition is to faciliate the usage of times 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
pip install TSInterpret
You can install the latest development version from GitHub as so:
pip install https://github.com/jhoelli/TSInterpret.git --upgrade
Or, through SSH:
pip install git@github.com:jhoelli/TSInterpret.git --upgrade
🍫 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
import pickle
import numpy as np
import matplotlib.pyplot as plt
import seaborn as snst
from tslearn.datasets import UCR_UEA_datasets
import tensorflow as tf
Create Classifcation Model
dataset='BasicMotions'
train_x,train_y, test_x, test_y=UCR_UEA_datasets().load_dataset(dataset)
enc1=pickle.load(open(f'../../ClassificationModels/models/{dataset}/OneHotEncoder.pkl','rb'))
train_y=enc1.transform(train_y.reshape(-1,1))
test_y=enc1.transform(test_y.reshape(-1,1))
model_to_explain = tf.keras.models.load_model(f'../../ClassificationModels/models/{dataset}/cnn/{dataset}best_model.hdf5')
Explain & Visualize Model
from TSInterpret.InterpretabilityModels.Saliency.TSR import TSR
int_mod=TSR(model_to_explain, train_x.shape[-2],train_x.shape[-1], method='IG',mode='time')
item= np.array([test_x[0,:,:]])
label=int(np.argmax(test_y[0]))
exp=int_mod.explain(item,labels=label,TSR =True)
%matplotlib inline
int_mod.plot(np.array([test_x[0,:,:]]),exp)
🏫 Affiliations
Citation
If you use TSInterpret in your research, please consider citing it and the methods authors' original papers. The methods authors' original papers are cited in the documentation and the paper below.
@misc{https://doi.org/10.48550/arxiv.2208.05280,
doi = {10.48550/ARXIV.2208.05280},
url = {https://arxiv.org/abs/2208.05280},
author = {Höllig, Jacqueline and Kulbach, Cedric and Thoma, Steffen},
keywords = {Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {TSInterpret: A unified framework for time series interpretability},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}
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
Hashes for TSInterpret-0.0.134-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a39c9f90ef729b4b38934147a4ae4431b6baa540eb1e4fade95dff88e2814fce |
|
MD5 | 3c1b808d9f856494360778ba1a66e2ec |
|
BLAKE2b-256 | d9526c222ec52c1426d42c509d812f53c608b00a4e67577df0ee3f306a22c800 |