1 of 42

Explainability and Interpretability in Graph Neural Networks

Nov 3rd, 2026

BMI/CS 775 Computational Network Biology�Fall 2026

Sushmita Roy, Prakriti Garg

https://bmi775.sites.wisc.edu

2 of 42

Goals for the next two lectures

  • Deep graph representation learning (Oct 29th)
    • Autoencoder
    • Graph AutoEncoder and Graph Variational AutoEncoder

​

  • Explainability/Interpreting Graph Neural Networks (Nov 3rd)

​

​

3 of 42

Goals for today

  • Background on Explainability
    • Non-graph based methods
  • Graph-based methods
  • GNNExplainer
  • Demo

​

​

​

4 of 42

Interpretability vs Explainability

  • We will use these interchangeably but.. it might be helpful to think about this a little
  • “A model is ‘interpretable’ if the model itself can provide humanly understandable interpretations of its predictions.” .. “such a model is no longer a black box to some extent. For example, a decision tree model is an ‘interpretable’ one”
  • “An ‘explainable’ model implies that the model is still a black box whose predictions could potentially be understood by post hoc explanation techniques”

​

​

1. Yuan, H., Yu, H., Gui, S. & Ji, S. Explainability in Graph Neural Networks: A Taxonomic Survey. IEEE Trans Pattern Anal Mach Intell 45, 5782–5799 (2023).

5 of 42

Why should we care about interpretability?

  • Help improve the model
    • Does a model take shortcuts/improve prediction error or learn causal/important features
    • Learn a simpler model

​

  • Explain why a model makes a particular prediction to justify a decision

​

  • Gain mechanistic insights

Christopher Molnar book on Interpretable Machine Learning: https://christophm.github.io/interpretable-ml-book/overview.html

6 of 42

Landscape of interpretability in ML models

Christopher Molnar book on Interpretable Machine Learning: https://christophm.github.io/interpretable-ml-book/overview.html

There are global, local model-specific methods too..

local

global

7 of 42

How to think about interpretability of ML models

  • Inherently interpretable/By design

​

  • Posthoc interpretability
    • Model agnostic/Black box interpretability

​

    • Model specific

8 of 42

Interpretable by design/Inherently interpretable

  • Linear regression and regularized versions
  • Logistic regression and regularized versions
  • Generalized Linear models (GLMs)
  • Generalized Additive Models (GAMs)
    • GLMs: “Keep the weighted sum of the features, but allow non-Gaussian outcome distributions and connect the expected mean of this distribution and the weighted sum through a nonlinear function”
  • Decision Trees

​

9 of 42

Posthoc Model Agnostic Interpretability

Model-agnostic approaches treat the model as a black box. They work directly with inputs and outputs

ML model

10 of 42

Common Model-Agnostic Interpretability tools

  • Perturbation-based methods
    • Local interpretable model-agnostic explanations (LIME), proposed by Ribeiro, Singh, and Guestrin (2016)
  • Surrogate methods
    • Local interpretable model-agnostic explanations (LIME), proposed by Ribeiro, Singh, and Guestrin (2016)
  • Shapley values: How much did a feature contribute to a prediction compared to the average prediction
  • SHAP: A game-theoretic approach to compute Shapley values (Lundberg & Lee, 2017)

​

​

​

​

11 of 42

Common Model-specific Interpretability tools

  • Feature importance of Random Forests (we have seen this before!)
  • Saliency maps or feature attribution methods
    • Gradient-based methods
      • Compute gradient with respect to input
      • May involve recomputing gradient based on changed inputs
      • Examples: Vanilla gradient, Grad-Class Activation Maps (Grad-CAM)
    • Path attribution
      • Integrated Gradients
    • DeepLIFT
    • Layerwise Relevance Propagation (LRP)

​

https://christophm.github.io/interpretable-ml-book/overview.html

12 of 42

Goals for today

  • Background on Explainability
    • Non-graph based methods
  • Explainability Methods for GNNs
  • GNNExplainer
  • Demo

​

​

​

13 of 42

XAI for GNNs: Why is it hard?

  • Graphs are relational, we want our explanation technique to capture this
  • Explanation can be at different units of the graph: node, edge, subgraphs
  • Graph attention can help, but insufficient for general explainability
    • Edge attention stays the same for all nodes where the edge is used for prediction

14 of 42

XAI for GNNs: Approaches

  • What components can we explain?
    • Node, edge, subgraph, entire graph
  • Methods maybe task-specific, e.g. node classification might use a set of methods different from link prediction
  • Approaches can be
    • model-specific vs model-agnostic
    • local/instance-based vs global

​

15 of 42

XAI for GNNs: Approaches

Yuan, H., Yu, H., Gui, S. & Ji, S. Explainability in Graph Neural Networks: A Taxonomic Survey. IEEE Trans Pattern Anal Mach Intell 45, 5782–5799 (2023).

16 of 42

Instance-based or Local methods

  • Gradient/Feature-based methods

​

  • Perturbation-based methods

​

  • Surrogate methods

​

  • Decomposition methods

​

​

​

Yuan, H., Yu, H., Gui, S. & Ji, S. Explainability in Graph Neural Networks: A Taxonomic Survey. IEEE Trans Pattern Anal Mach Intell 45, 5782–5799 (2023).

17 of 42

Gradient-based or feature-based methods

  • Typically use standard/generic methods for other ML models
  • Gradient-based methods compute the gradient with respect to input as part of backpropagation
    • SA Squared value of gradients
    • Guided BP: Guided Backpropagation
    • CAM: class activation map
    • Grad-CAM: Gradient-weighted Class Activation Map

​

​

 

 

18 of 42

Perturbation-based XAI methods for GNNs

  • Overall idea: how does the output vary due to perturbations in the input?
  • Inputs can be varied at the node, edge, feature level
  • Example methods:
    • GNNExplainer, PGExplainer, ZORRO, GraphMask, SubgraphX, ReFine

Yuan, H., Yu, H., Gui, S. & Ji, S. Explainability in Graph Neural Networks: A Taxonomic Survey. IEEE Trans Pattern Anal Mach Intell 45, 5782–5799 (2023).

19 of 42

Surrogate methods

  • Overall idea: Use a simpler “surrogate” model to approximate prediction, fitting the simpler model around the neighborhood of the input
  • Methods differ in how the neighborhood is obtained and what simpler models are used
  • Examples: GraphLIME, PGM-Explainer, RelEx

​

20 of 42

Decomposition methods

  • Overall idea: Backpropagate the output from the output layer back to the input
  • Example methods: GNN-LRP

​

21 of 42

Benchmarking XAI methods for graphs

  • Various metrics have been used to assess explainability methods
    • Accuracy
    • Faithfulness/Fidelity
    • Stability
    • Sparsity

​

Agarwal, C., Queen, O., Lakkaraju, H. & Zitnik, M. Evaluating explainability for graph neural networks. Sci Data 10, 144 (2023).

22 of 42

TopHat

23 of 42

Goals for today

  • Background on Explainability
    • Non-graph based methods
  • Explainability Methods for GNNs
  • GNNExplainer
  • Demo

​

​

​

24 of 42

GNNExplainer – Generating Explanations for GNNs

  • Local, Post-hoc, Model agnostic
  • identifies compact subgraph structure and a subset of node features that are important for GNN’s prediction

25 of 42

GNNExplainer learns structural and feature explanation simultaneously

Structural explanation

Feature explanation

Optimizes for masks that learn structure and feature explanation

26 of 42

GNNExplainer input notation

Consider a node classification task for node v�

  • Input graph: Gc(v) -> L-hop computation graph
  • Adjacency matrix of Gc(v) : Ac(v) ∈ {0,1}n×n
  • Node feature: Xc(v) = {xj : vj ∈ Gc(v)}

​

  • The trained GNN model Φ maps this graph and its node features to a class distribution
      • PΦ(Y | Ac(v), Xc(v))

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

G

G꜀(v)

v

v

L-hop graph

27 of 42

What the explanation returns

  • GNNExplainer describes one prediction with important sub-graph structure and node features.
  • GS ⊆ Gc(v) and AS is its adjacency matrix.

XSF = {xjF : vj ∈ GS}

xjF = [xj,t₁, …, xj,tₖ]�

  • The pair (GS, XSF) is the compact explanation for the prediction being explained.

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

Gₛ example

v

28 of 42

Mutual information (MI) objective

  • MI(·;·) is mutual information
    • Measure of shared information between 2 random variables.

​

  • Maximize MI over label and explanation

max over GS MI(Y ; (AS, XSF))

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

https://en.wikipedia.org/wiki/Mutual_information

29 of 42

From mutual information to conditional entropy

  •  

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

Fixed!

ChatGPT helped in writing intermediate equations

30 of 42

Why the graph search is relaxed

  • With m = |Ec| candidate edges, a hard mask (i.e binary 0 or 1 mask) has exponential possible subgraphs!
    • checking all impractical
  • We approximate the sampled-subgraph objective using a continuous, weighted adjacency matrix.

​

  • Learn a distribution over possible subgraphs that minimizes the average prediction uncertainty.
      • min over G EG_S ~ G [ H(Y | G = GS, X = XS)

  • Instead of evaluating many sampled subgraphs, use a single weighted graph where each edge weight represents its probability of being retained
      • min over G H(Y | G = EG [GS], X = XS) ]

​

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

31 of 42

Learning the structural edge mask

  • A trainable edge mask turns discrete edge choices into differentiable weights.

Ãc(v) = Ac(v) ⊙ σ(M), M ∈ ℝn×n�

  • M contains trainable logits
      • σ(M)ij ∈ (0,1) is the mask weight for input edge (i,j). �
  • The symbol ⊙ means element-wise multiplication.�
  • Lpred(M) = − log PΦ(Y = y | G = Ãc(v), X = XSF)]�
  • Since Ãc = Ac ⊙ σ(M), an edge absent from the input graph cannot be added.�
  • Freeze Φ; update M by gradient descent

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

32 of 42

Learning the node feature mask

  • A separate mask asks which feature dimensions of the important subset nodes matter for this prediction.

XSF = { xj ⊙ F : vj ∈ GS }

  • Ft-> 1 means feature dimension t is important
  • Sample a baseline feature vector Z from the empirical distribution and use:

X = Z + (XS − Z) ⊙ F, ∑t Ft ≤ KF

  • This sampling with reparameterization lets gradients reach F.
  • KF limits the number of feature dimensions kept.

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

33 of 42

Regularization

  • Prediction alone can keep too many edges or feature dimensions, so the objective adds size and discreteness penalties.
  • One objective:
  • L = Lpred + λE sum(σ(M)) + λF sum(σ(F)) + βE H(σ(M)) + βF H(σ(F))�

​

​

​

​

​

​

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

a smaller sum of weights favors a shorter explanation

​

For one mask value p:

h(p) = −p log p − (1−p) log(1−p)

​

h(p) is largest at 0.5 and smallest at 0 or 1. Adding entropy to minimize loss discourages weights near 0.5 which are ambiguous.

34 of 42

Optimization, one update at a time

  • The trained GNN is queried repeatedly. Only the explanation masks are optimized.
    • 1 Fix GNN Φ and target ŷ; extract Gc(v), Ac(v), and Xc(v).
    • 2 Initialize M and F; apply σ(M) to edges and F to features.
    • 3 Run Φ on the masked inputs; compute prediction loss plus mask penalties.
    • 4 Backpropagate M and F, update them and repeat. Keep GNN Φ frozen.
  • 5 Threshold learned masks to infer a discrete subgraph and selected feature dimensions.
    • Initialization, regularization and thresholding can change the final mask.

Colors: blue input; orange edge mask; pink feature mask; green selected; purple prediction

35 of 42

Datasets used for evaluation

36 of 42

Explanation accuracy

37 of 42

Explanation subgraphs

38 of 42

Relating GNNExplainer to PPI interpretation

  • Suppose a node-classification GNN predicts that target protein v is essential. Its input is the local PPI computation graph around v.
  • The edge mask scores candidate interactions, the feature mask scores the node-feature dimensions supplied to the model.
  • The green subgraph keeps important paths which combined with selected features preserve the model’s essential prediction.
  • Note - this describes the fitted GNN’s reasoning for this node.
    • It does not show that the interactions cause essentiality in biology.
    • Deletion can check for necessity

39 of 42

How to assess an explanation

  • Fidelity: does the selected subgraph and feature set retain the prediction?�
  • Necessity: does removing selected edges or features reduce the explained class score?�
  • Sufficiency: does keeping only the selected subgraph and features preserve the class score?

40 of 42

Demo

  • This is the official demo on cora dataset which we also referred to in the class

​

41 of 42

PyGeometric Interpretability links

42 of 42

References

  • Interpretable Machine Learning. https://christophm.github.io/interpretable-ml-book/.
  • Yuan, H., Yu, H., Gui, S. & Ji, S. Explainability in Graph Neural Networks: A Taxonomic Survey. IEEE Trans Pattern Anal Mach Intell 45, 5782–5799 (2023).
  • Ying, Z., Bourgeois, D., You, J., Zitnik, M. & Leskovec, J. GNNExplainer: Generating Explanations for Graph Neural Networks. in Advances in Neural Information Processing Systems vol. 32 (Curran Associates, Inc., 2019).
  • Agarwal, C., Queen, O., Lakkaraju, H. & Zitnik, M. Evaluating explainability for graph neural networks. Sci Data 10, 144 (2023).
  • Lundberg, S. & Lee, S.-I. A Unified Approach to Interpreting Model Predictions. Preprint at https://doi.org/10.48550/arXiv.1705.07874 (2017).

​

​

​

​

​

​