Skip to main content

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 pip:

git clone git@github.com:babylonhealth/time_interpret.git
cd time_interpret
pip install -e .

or 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:

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})

Methods (under development)

Acknowledgment

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

time_interpret-0.2.1.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

time_interpret-0.2.1-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

Details for the file time_interpret-0.2.1.tar.gz.

File metadata

  • Download URL: time_interpret-0.2.1.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

Hashes for time_interpret-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7cd69a854556cb606adfde9840c04a8d2c9607c5d18df7fcc0bdc86ad592248d
MD5 8c595ecc3d4cece841c8d445b17b10cc
BLAKE2b-256 1ba8486a7e7d09327305ffbb73f8491e16a157094f768fecb6e4bbea1458283a

See more details on using hashes here.

File details

Details for the file time_interpret-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for time_interpret-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 100ea23ab961914d431257895d7e291f7d804ab9ac747b8dd0de85642e65a09e
MD5 bc29734e00f84cf3ada5292cd949f5e4
BLAKE2b-256 ea4f091107c17781a42c1248b4996c0ad1142ffe2a297cf732d06a0e385df78c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page