A robust SHAP explainer wrapper for PyTorch Geometric models.
Project description
PyG-SHAP
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:
- Intercepts Captum's corrupted sampling tensors.
- Safely reconstructs the block-diagonal graph batches on-the-fly.
- Allows for seamless SHAP and Integrated Gradients attribution on complex PyG architectures (GAT, GCN, Transformers).
Installation
pip install pyg-captum-shap
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyg_captum_shap-0.1.2.tar.gz.
File metadata
- Download URL: pyg_captum_shap-0.1.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35801e627e3e202f34e1c1be8fff06dab95a8bb7352b428a3863c03fbcc52cd1
|
|
| MD5 |
493a85f06748290b185bf2295410cbaa
|
|
| BLAKE2b-256 |
93702c4fa24318453701727d69da8e3b06462b5d542acade4a18133bd4cd20ca
|
File details
Details for the file pyg_captum_shap-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pyg_captum_shap-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a093de97bafb3ad07437f18108b372e156ba69fc42c660b3fbc7e2e9de5e5b2
|
|
| MD5 |
cebc4c570659c0cc528c12ae1053a7f4
|
|
| BLAKE2b-256 |
efd5529c9f9ea4db206f981fb8b47437ff624ff8176031740e9c12a9ab9deb9a
|