Code Monkey home page Code Monkey logo

gnn-model-explainer's Introduction

gnn-explainer

This repository contains the source code for the paper GNNExplainer: Generating Explanations for Graph Neural Networks by Rex Ying, Dylan Bourgeois, Jiaxuan You, Marinka Zitnik & Jure Leskovec, presented at NeurIPS 2019.

[Arxiv] [BibTex] [Google Scholar]

@misc{ying2019gnnexplainer,
    title={GNNExplainer: Generating Explanations for Graph Neural Networks},
    author={Rex Ying and Dylan Bourgeois and Jiaxuan You and Marinka Zitnik and Jure Leskovec},
    year={2019},
    eprint={1903.03894},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}

Using the explainer

Installation

See INSTALLATION.md

Replicating the paper's results

Training a GCN model

This is the model that will be explained. We do provide pre-trained models for all of the experiments that are shown in the paper. To re-train these models, run the following:

python train.py --dataset=EXPERIMENT_NAME

where EXPERIMENT_NAME is the experiment you want to replicate.

For a complete list of options in training the GCN models:

python train.py --help

TODO: Explain outputs

Explaining a GCN model

To run the explainer, run the following:

python explainer_main.py --dataset=EXPERIMENT_NAME

where EXPERIMENT_NAME is the experiment you want to replicate.

For a complete list of options provided by the explainer:

python train.py --help

Visualizing the explanations

Tensorboard

The result of the optimization can be visualized through Tensorboard.

tensorboard --logdir log

You should then have access to visualizations served from localhost.

Jupyter Notebook

We provide an example visualization through Jupyter Notebooks in the notebook folder. To try it:

jupyter notebook

The default visualizations are provided in notebook/GNN-Explainer-Viz.ipynb.

Note: For an interactive version, you must enable ipywidgets

jupyter nbextension enable --py widgetsnbextension

You can now play around with the mask threshold in the GNN-Explainer-Viz-interactive.ipynb.

TODO: Explain outputs + visualizations + baselines

D3,js

We provide export functionality so the generated masks can be visualized in other data visualization frameworks, for example d3.js. We provide an example visualization in Observable.

Included experiments

Name EXPERIMENT_NAME Description
Synthetic #1 syn1 Random BA graph with House attachments.
Synthetic #2 syn2 Random BA graph with community features.
Synthetic #3 syn3 Random BA graph with grid attachments.
Synthetic #4 syn4 Random Tree with cycle attachments.
Synthetic #5 syn5 Random Tree with grid attachments.
Enron enron Enron email dataset source.
PPI ppi_essential Protein-Protein interaction dataset.
Reddit* REDDIT-BINARY Reddit-Binary Graphs (source).
Mutagenicity* Mutagenicity Predicting the mutagenicity of molecules (source).
Tox 21* Tox21_AHR Predicting a compound's toxicity (source).

Datasets with a * are passed with the --bmname parameter rather than --dataset as they require being downloaded manually.

TODO: Provide all data for experiments packaged so we don't have to split the two.

Using the explainer on other models

A graph attention model is provided. This repo is still being actively developed to support other GNN models in the future.

Changelog

See CHANGELOG.md

gnn-model-explainer's People

Contributors

rexying avatar dtsbourg avatar jiaxuanyou avatar hnaik avatar devloop0 avatar stannislav avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.