Skip to main content

A robust SHAP explainer wrapper for PyTorch Geometric models.

Project description

PyG-Captum-SHAPS

A robust wrapper bridging the Euclidean sampling mechanisms of Captum with the non-Euclidean batching of PyTorch Geometric (PyG). Designed specifically for molecular QSAR modelling. This library is built on top of the Captum library by PyTorch.

This library provides a Dictionary-Shielded Wrapper that:

  1. Intercepts Captum's corrupted sampling tensors.
  2. Safely reconstructs the block-diagonal graph batches on-the-fly.
  3. Allows for seamless SHAP and Integrated Gradients attribution on complex PyG architectures (GAT, GCN, Transformers).

Installation

pip install pyg-captum-shaps

Quick Start

from pyg_captum_shap import compute_shap_values

# Extract SHAP values for a specific molecule and task
node_attributions = compute_shap_values(
    model=your_trained_model,
    target_graph=molecule_graph_data,
    target_task=0
)

# node_attributions now contains the importance score for every atom in the graph

License

Distributed under the MIT License.

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

pyg_captum_shap-0.1.4.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyg_captum_shap-0.1.4-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file pyg_captum_shap-0.1.4.tar.gz.

File metadata

  • Download URL: pyg_captum_shap-0.1.4.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for pyg_captum_shap-0.1.4.tar.gz
Algorithm Hash digest
SHA256 cfbb770d60476ef0a44a8b9f198ce1d3f0c9ec05d2b9b2c28a36fdf1af569321
MD5 95366c504e5f512d85bcab11500a1f7a
BLAKE2b-256 25d0e939f1b8e5fb21df7f3b024dbaa5702aa5a7ce89a6be84c267bd25e26d34

See more details on using hashes here.

File details

Details for the file pyg_captum_shap-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pyg_captum_shap-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2c299c4e6495f6d5e4667febc4991bc21ff2c8c8dd2d01a05b00e807568f7b69
MD5 a9d1c7e0e523c28166c302a444d4da13
BLAKE2b-256 c22e9cadebcdb91e192a0eb93c4a1b058427115f3f7fbaecad4c2c59b81d1772

See more details on using hashes here.

Supported by

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