fzi-forschungszentrum-informatik / TSInterpret

An Open-Source Library for the interpretability of time series classifiers
BSD 3-Clause "New" or "Revised" License
116 stars 8 forks source link

the code examples in the README.md only works if the user downloaded the git repo #18

Closed ulf1 closed 1 year ago

ulf1 commented 1 year ago

https://github.com/fzi-forschungszentrum-informatik/TSInterpret/blob/345942838dbe3fa6526c0bd0659a405271ea5117/README.md?plain=1#L50

the code examples in the README.md only works if the user downloaded the git repo but not via the pypi package. You should also give the instruction to download the git repo to run the examples.

ulf1 commented 1 year ago
mkdir myproject
cd myproject

# setup virtualenv or conda ...
# install software
pip install TSInterpret

# download demo examples
git clone git@github.com:fzi-forschungszentrum-informatik/TSInterpret.git

python3

then

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 

# the path are different. 
# i don't know why the original example refers to '../../' 
dataset='BasicMotions'
train_x,train_y, test_x, test_y=UCR_UEA_datasets().load_dataset(dataset)
enc1=pickle.load(open(f'TSInterpret/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'TSInterpret/ClassificationModels/models/{dataset}/cnn/{dataset}best_model.hdf5')
ulf1 commented 1 year ago

Is there also a function to save a PNG file to disk instead of using Jupyter?

%matplotlib inline  
int_mod.plot(np.array([test_x[0,:,:]]),exp)
JHoelli commented 1 year ago

Hi ,

I added clarifications to the ReadMe.md. Usually the classification models are not provided by our package. The intention is to provide insights into the models customized by the users of this package. Therefore, classification models are not included in the PyPi installation and only available by cloning this repo. I hope the current version is now clearer. @ulf1 If you have ideas on how to make this more elegant, feel free to share those.

Yes the plot function has a parameter called save where you can specify the path to save the images (.png/.jpg/.svg).

Best, Jacqueline