todo
Project description
TSInterpret
TSInterpret is a Python library for interpreting time series classification. The ambition is to faciliate the usage of times series interpretability methods.
💈 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 Supported Vector Classifer based on tslearn and interprets the Classfier by creating a counterfactual. For further examples check out the Documentation.
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.SaliencyMethods_TF import Saliency_TF
int_mod=Saliency_TF(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
Aknowledgement
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
TSInterpret-0.0.11.tar.gz
(49.5 kB
view hashes)
Built Distribution
Close
Hashes for TSInterpret-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d7e4fcfe1d8fab6858200591868fd0f39dc0d574cf024416c12cc4c07524914 |
|
MD5 | 2072aa5f8c65fc8a485fe20112441362 |
|
BLAKE2b-256 | 9e9bd46ba0c40d32fcd28c7502cef2c8fad40430b2522751ae8d9c2de2b65a81 |