GithubHelp home page GithubHelp logo

fork123aniket / model-agnostic-graph-explainability-from-scratch Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 3.16 MB

Implementation of Model-Agnostic Graph Explainability Technique from Scratch in PyTorch

Home Page: https://pytorch-geometric.readthedocs.io/en/latest/modules/contrib.html#torch_geometric.contrib.explain.GraphMaskExplainer

License: MIT License

Python 100.00%
explainability explainable-ai explainable-machine-learning explainable-ml explainer explanations graph-neural-networks pytorch pytorch-geometric pytorch-implementation

model-agnostic-graph-explainability-from-scratch's Introduction

Model-agnostic Graph Explainability from Scratch

This repository holds a graph explainability solution, which extends the work (GraphMask Explainer) to heterogeneous as well as homogeneous Graphs, making this functionality model-agnostic. Moreover, this implementation provides both node feature-level and edge-level attributes mask (explanation subgraph), which is a binary-valued vector. All 0 values of this mask vector represent those features (and edges) of the graph that do not affect their corresponding predictions, whereas features (and edges) associated with 1 values consider to be a lot effective in influencing their associated predictions outputted by the original Graph Neural Network (GNN) model.

Requirements

  • PyTorch Geometric
  • PyTorch
  • numpy
  • scikit-learn
  • tqdm

Usage

Data

This implementation of GraphMask Explainer demonstrates explainability examples for GCN, GAT, and RGCN layer-types on Node Classification (NC), Graph Classification (GC), and Link Prediction (LP) tasks.

Layer Type Task Dataset
GCN NC Cora
GCN GC Enzymes
GAT NC Cora
GAT GC Enzymes
GAT LP Cora
RGCN NC AIFB
RGCN GC Enzymes

Training and Testing

  • To see the model-agnostic explainability layer’s implementation, check graphmask_explainer.py.
  • To train the GraphMask Explainer and generate explanations for any of the aforementioned tasks, run graphmask_explainer_example.py.
  • All hyperparameters’ settings can be tweaked (based on requirements) by altering their corresponding values provided in both graphmask_explainer.py and graphmask_explainer_example.py files.

Results

NC Task Explanation Subgraph (AIFB Dataset) GC Task Explanation Subgraph (Enzymes Dataset)
alt text alt text

These figures show output subgraph in which all irrelevant edges (having 0 values in the binary-valued mask) have been colored grey, whereas all relevant edges (having 1 values in the generated binary-valued mask) have been illustrated in black color. Note that, for NC task, the output subgraph contains only those nodes that lie within the 3-hop neighborhood of the parent node with index 20 and have the same relation type as the parent node has, on the other hand, for GC task, the output subgraph demonstrates explanations of the graph with index 10 present in Enzymes dataset.

model-agnostic-graph-explainability-from-scratch's People

Contributors

fork123aniket avatar

Stargazers

 avatar

Watchers

 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.