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

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.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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

Hashes for time_interpret-0.2.0.tar.gz
Algorithm Hash digest
SHA256 93ca9172615da972dc3cedd28f1552070f8da0fb1d9599bdc02fdf7e80aa504f
MD5 f0bc774559cb79e642e9d881d06fcd49
BLAKE2b-256 48ce63c27f3887c0c90dce8564abc320966729f9a1e2a18fc4e0ae6b5cb426b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for time_interpret-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cd10aa2918aab2d742322269bb4ab98b886edf785d55a078e11db430d221008
MD5 a63af1c95924c6eebaa4df3251bbae84
BLAKE2b-256 8b723decfc14ca4fdd4dcec6a628c21f56a7b7c24beaefb2cf95ada7bd95fa3a

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