Giter Site home page Giter Site logo

graphlime's Introduction

GraphLIME

GraphLIME is a model-agnostic, local, and nonlinear explanation method for GNN in node classfication task. It uses Hilbert-Schmit Independence Criterion (HSIC) Lasso, which is a nonlinear interpretable model. More details can be seen in the paper.

This repo implements GraphLIME by using the awasome GNN library PyTorch Geometric, and reproduces the results of filtering useless features until now; that is, Figure 3 in the paper.

Installation

Just use pip to install.

> pip install graphlime

Usage

This implementation is easy to use. All you need to do is to confirm that your model outputs log probabilities (for example, outputs by F.log_softmax()) first, then instantiate a GraphLIME object, and finally explain the specific node by calling explain_node() method.

from graphlime import GraphLIME

data = ...  # a `torch_geometric.data.Data` object
model = ... # any GNN model
node_idx = 0  # the specific node to be explained

explainer = GraphLIME(model, hop=2, rho=0.1)
coefs = explainer.explain_node(node_idx, data.x, data.edge_index)

coefs are the coefficients of features. They correspond to the ๐œท in the paper. The larger the value is, more important the corresponding feature is.

Tutorial

Example and details can be found in tutorial.ipynb.

Reproduce

All scripts of different experiments are in the scripts folder. You can reproduce the results by running the following command:

> sh scripts/noise_features_cora.sh

Results

Filter Unuseless Features

There are another 10 random features added to the original features and then we train a GNN model. We use several explanation methods to find out which features are important for the model. Then we plot the distribution of noise features selected by the explanation methods. Less noise features are better; that is, a peak around the origin is good.

Requirements

  • python >= 3.6
  • torch >= 1.6.0
  • torch-geometric 1.6.0
  • numpy 1.17.2
  • scikit-learn 0.21.3
  • seaborn 0.10.1
  • matplotlib 2.2.4

Changing Log

  • 2021-02-13: add GNNExplainer in the noise features experiment
  • 2021-02-05: add a tutorial file
  • 2021-01-10: modified the file structure & published to PyPI with version 1.2.0
  • 2020-11-26: fixed bug
  • 2020-11-09: fixed bug
  • 2020-10-08: modified the file structure for publishing to PyPI
  • 2020-05-26: first uploaded

graphlime's People

Contributors

williamcchuang 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.