Skip to main content

Time interpret library for PyTorch.

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: time_interpret-0.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 cde538645ef6b059586e216cbe343d409efe13f2ffad119d0f794d82aa736a24
MD5 ba484be90ccce6f27702ab82761a4a99
BLAKE2b-256 e73a43af22e2a6a80c69f73e406e4a78ac432656e7386c04e6579de29c55f706

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for time_interpret-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba967904c631099802e369bf67a702bd5f466c6bb6916b2a6fc9745c66ef2ab7
MD5 b3a619dcb3421c55aaf6024c7c23de9a
BLAKE2b-256 91309a37461860af6cd39e547e1f71e966eac3b0945f04e11df932f457a57eb1

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