Model interpretability library for PyTorch with a focus on time series.
Project description
Time Interpret (tint)
This package expands the captum library with a specific focus on time series. Please see the documentation and examples for more details.
Install
Time Interpret can be installed with pip:
pip install time_interpret
or from source with conda:
git clone git@github.com:babylonhealth/time_interpret.git
cd time_interpret
conda env create
source activate tint
pip install --no-deps -e .
Quick-start
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:
x = arma.preprocess()["x"][0]
true_saliency = arma.true_saliency(dim=rare_dim)[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)
baseline = inputs * 0
attr = explainer.attribute(
inputs,
baselines=inputs * 0,
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})
Methods (under development)
- AugmentedOcclusion
- BayesLime
- BayesShap
- DynaMask
- Discretised Integrated Gradients
- Fit
- Occlusion
- Retain
- SmoothGrad
Acknowledgment
- 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.
Project details
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
File details
Details for the file time_interpret-0.2.0.tar.gz
.
File metadata
- Download URL: time_interpret-0.2.0.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93ca9172615da972dc3cedd28f1552070f8da0fb1d9599bdc02fdf7e80aa504f |
|
MD5 | f0bc774559cb79e642e9d881d06fcd49 |
|
BLAKE2b-256 | 48ce63c27f3887c0c90dce8564abc320966729f9a1e2a18fc4e0ae6b5cb426b6 |
File details
Details for the file time_interpret-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: time_interpret-0.2.0-py3-none-any.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cd10aa2918aab2d742322269bb4ab98b886edf785d55a078e11db430d221008 |
|
MD5 | a63af1c95924c6eebaa4df3251bbae84 |
|
BLAKE2b-256 | 8b723decfc14ca4fdd4dcec6a628c21f56a7b7c24beaefb2cf95ada7bd95fa3a |