This library expands the captum library with a specific focus on time series. For more details, please see the documentation and our paper.
Time Interpret can be installed with pip:
pip install time_interpret
Please see the documentation for alternative installation modes.
First, let's load an Arma dataset:
from tint.datasets import Arma
arma = Arma()
arma.download() # This method generates the dataset
We then load some test data from the dataset and the corresponding true saliency:
inputs = arma.preprocess()["x"][0]
true_saliency = arma.true_saliency(dim=1)[0]
We can now load an attribution method and use it to compute the saliency:
from tint.attr import TemporalIntegratedGradients
explainer = TemporalIntegratedGradients(arma.get_white_box)
baselines = inputs * 0
attr = explainer.attribute(
inputs,
baselines=baselines,
additional_forward_args=(true_saliency,),
temporal_additional_forward_args=(True,),
).abs()
Finally, we evaluate our method using the true saliency and a white box metric:
from tint.metrics.white_box import aup
print(f"{aup(attr, true_saliency):.4}")
- AugmentedOcclusion
- BayesKernelShap
- BayesLime
- Discretized Integrated Gradients
- DynaMask
- ExtremalMask
- Fit
- LofKernelShap
- LofLime
- Non-linearities Tunnel
- Occlusion
- Retain
- SequentialIntegratedGradients
- TemporalAugmentedOcclusion
- TemporalOcclusion
- TemporalIntegratedGradients
- TimeForwardTunnel
This package also provides several datasets, models and metrics. Please refer to the documentation for more details.
The experiments for the paper: Learning Perturbations to Explain Time Series Predictions can be found on these folders:
Paper: Sequential Integrated Gradients: a simple but effective method for explaining language models
The experiments for the paper: Sequential Integrated Gradients: a simple but effective method for explaining language models can be found on the NLP section of the experiments.
More methods to interpret predictions of time series classifiers have been grouped into TSInterpret, another library with a specific focus on time series. We developed Time Interpret concurrently, not being aware of this library at the time.
- Jonathan Crabbe for the DynaMask implementation.
- Sana Tonekaboni for the fit implementation.
- INK Lab for the discretized integrated gradients' implementation.
- Dylan Slack for the BayesLime and BayesShap implementations.