This repository contains the source code of
GNNShap: Scalable and Accurate GNN Explanation using Shapley Values paper accepted in The
Web Conference 2024.
Our implementation is based on PyTorch and PYG. Also, Our Shapley sampling strategy is implemented in Cuda. Therefore, GNNShap requires a GPU with Cuda support.
First install PyTorch with GPU support from here and make sure PyTorch is using GPU.
The rest of the required packages and versions are provided in the requirements.txt file.
You can install the requirements by running:
pip install -r requirements.txtDataset and dataset-specific model configurations are in the dataset/configs.py file.
We provided pretrained models in the pretrained folder.
To train Cora, CiteSeer, PubMed, Coauthor-CS, Coauthor-Physics, and Facebook datasets:
python train.py --dataset CoraReddit and ogbn-products require NeighborLoader for training. To train them:
python train_large.py --dataset RedditWe provided scripts for baselines and GNNShap experiments. Scripts will save explanation results to the results folder. Note that scripts repeat each experiment five times. This can be changed in the scripts.
For baselines, you can use the following script. For individual baseline, you can refer to the script file content.
./run_baseline_experiments.shFor GNNShap experiments, you can use the following script:
./run_gnnshap_experiments.sh
- We ran experiments on a GPU with 24GB of memory. You may need to adjust
batch_sizeandnum_samplesparameters if you have less GPU memory. - The first run might take some time: it needs to compile the Cuda code.
For individual dataset experiments, an example is provided below:
python run_gnnshap.py --dataset Cora --num_samples 25000 --sampler GNNShapSampler
--batch_size 1024 --repeat 1The results will be saved to the results folder. The default result folder can be changed
in dataset/configs.py
We used the BaselinesEvaluation.ipynb notebook under the examples folder for explanation times
and fidelity results.
We provided explanation visualization examples in the Visualization.ipynb notebook
under examples.
We provided an example in the CustomModelData.ipynb notebook under examples.
Please cite our work if you find it useful.
Selahattin Akkas and Ariful Azad. 2024. GNNShap: Scalable and Accurate GNN Explanation using Shapley Values.
In Proceedings of the ACM Web Conference 2024 (WWW ’24), May 13–17, 2024, Singapore, Singapore.