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_gat_shap_values

# Extract SHAP values for a specific molecule and task
node_attributions = compute_gat_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.3.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.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyg_captum_shap-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 f8a4ad93010f4affd982ad841acae8bc97f76e087da5cb67506a3ad8ae4bbfc5
MD5 dff7b8c8a2edf7a5167aa123821bd5b2
BLAKE2b-256 87dfc73066d61347a759ff9742f019f08997697ca087e8cedc65c26cebe8e98c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyg_captum_shap-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8657ff5d915e4a0834adf37153333bff0860316577278e70ff83ced96504d3d7
MD5 a05bae18bc662878498e330e7aa2b6cb
BLAKE2b-256 c3159c8e5376a6bb8f9702e7c609ea0ef31b1080caa873f10202b6ff8ecacc1c

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