Explaining Graph Neural Networks
Fabrizio Silvestri
Artificial Intelligence for Biomedical Applications - AI4BA 2024
26 Giugno 2024
Introduction to eXplainable AI (XAI)
Where we begin our journey on XAI…
AI4BA 2024 - June 26, 2024
Complexity vs. Explainability
AI4BA 2024 - June 26, 2024
Simple models are less expressive but explainable
Simple Decision Boundary Surface
Complexity vs. Explainability
AI4BA 2024 - June 26, 2024
Complex models are more effective but opaque
Convoluted Decision Boundary Surface
The Need for XAI
AI4BA 2024 - June 26, 2024
The Need for XAI
AI4BA 2024 - June 26, 2024
What Does Explainable Mean?
AI4BA 2024 - June 26, 2024
Decision Trees
Linear Regression
What Does Explainable Mean?
AI4BA 2024 - June 26, 2024
Natural Language Processing
Computer Vision
What Does Explainable Mean?
AI4BA 2024 - June 26, 2024
Properties of Explanations
AI4BA 2024 - June 26, 2024
Properties of Explanations
AI4BA 2024 - June 26, 2024
Properties of Explanations
AI4BA 2024 - June 26, 2024
Properties of Explanations
AI4BA 2024 - June 26, 2024
Evaluating Explanations
AI4BA 2024 - June 26, 2024
Evaluating Explanations
AI4BA 2024 - June 26, 2024
Evaluating Explanations
AI4BA 2024 - June 26, 2024
Local vs. Global Explanations
AI4BA 2024 - June 26, 2024
Do we explain individual predictions?
Examples:
Heatmaps, Rationales
Do we explain the entire model?
Examples:
Linear Regression, Decision Trees, Prototypes
Local Explanations
Global Explanations
Ante vs. Post Hoc Explanations
AI4BA 2024 - June 26, 2024
Is the model inherently explainable?
Examples:
Rationales, Linear Regression, Decision Trees
Do we need an external method to explain the black-box model?
Examples:
Heatmaps (some), Counterfactuals
Ante-Hoc
Post-Hoc
Model-Based vs Model-Agnostic Explanations
AI4BA 2024 - June 26, 2024
Can it explain only one model?
Examples:
Rationales, Linear Regression, Decision Trees, Attention, Gradients (differentiable), GNNs
Can it explain any model?
Examples:
LIME (Locally Interpretable Model-Agnostic Explanations), SHAP (Shapley Values), ReLAX
Model-Based
Model-Agnostic
Two (famous) Examples
Where we continue our journey with two examples on data different than graphs …
Slides courtesy of Prof. Gabriele Tolomei.
AI4BA 2024 - June 26, 2024
Explainable AI: Taxonomy
Explainable AI: Taxonomy
LIME �(Locally Interpretable Model-Agnostic Explanations)
black box
(e.g., deep NN)
LIME �(Locally Interpretable Model-Agnostic Explanations)
black box
(e.g., deep NN)
LIME �(Locally Interpretable Model-Agnostic Explanations)
black box
(e.g., deep NN)
LIME �(Locally Interpretable Model-Agnostic Explanations)
black box
(e.g., deep NN)
(linear model)
LIME �(Locally Interpretable Model-Agnostic Explanations)
black box
(e.g., deep NN)
(linear model)
LIME �(Locally Interpretable Model-Agnostic Explanations)
black box
(e.g., deep NN)
(linear model)
As close as possible
LIME: Intuition
LIME: Example (Image Classification)
A data point (image)
LIME: Example (Image Classification)
A data point (image)
black box
LIME: Example (Image Classification)
A data point (image)
black box
"frog"
Its predicted class
LIME: Example (Image Classification)
A data point (image)
black box
"frog"
Its predicted class
Why Does the Model Output "frog"?
LIME: Example (Image Classification)
Represent each image as a set of superpixels (segments)
LIME: Example (Image Classification)
Represent each image as a set of superpixels (segments)
Randomly delete some segments to generate samples in the neighborhood of the data point to explain
LIME: Example (Image Classification)
Input these samples to the black-box model and compute P("frog" | )…
black box
black box
black box
LIME: Example (Image Classification)
Use predictions from the black-box as labels to train a linear model
0.85
0.52
0.01
M = #segments
black-box labels
LIME: Example (Image Classification)
Interpret the model just learned
LIME: Example (Image Classification)
Interpret the model just learned
For each segment i, look at the corresponding weight
LIME: Example (Image Classification)
Interpret the model just learned
For each segment i, look at the corresponding weight
Segment i is not related to "frog"
LIME: Example (Image Classification)
Interpret the model just learned
For each segment i, look at the corresponding weight
Segment i is not related to "frog"
Segment i indicates the image is "frog"
LIME: Example (Image Classification)
Interpret the model just learned
For each segment i, look at the corresponding weight
Segment i is not related to "frog"
Segment i indicates the image is "frog"
Segment i indicates the image is not "frog"
LIME: Pseudocode
Explainable AI: Taxonomy
SHAP: Feature Attribution
SHAP: Feature Attribution
SHAP: Feature Attribution
SHAP: Feature Attribution
SHAP: Feature Attribution
SHAP: Feature Attribution
SHAP: Shapley Values
SHAP: Shapley Values
SHAP: Shapley Values
SHAP: Shapley Values
SHAP: Shapley Values
Weighted average across
SHAP: Shapley Values
Weighted average across
Contribution from adding player
SHAP: Shapley Values
Given an ordering, each player contributes when added to the preceding ones:
SV is the average contribution across all orderings
Intuitive meaning in terms of player orderings
SHAP: Application to ML/AI
SHAP: Application to ML/AI
SHAP: Application to ML/AI
SHAP: Application to ML/AI
Feature Importance vs. SHAP Importance
Wine Dataset
Feature Importance vs. SHAP Importance
Wine Dataset
Training XGBoost for binary classification
Feature Importance vs. SHAP Importance
Wine Dataset
Training XGBoost for binary classification
Feature Importance
Feature Importance vs. SHAP Importance
Wine Dataset
Training XGBoost for binary classification
Feature Importance
`Total Sulfur Dioxide` is the most important feature according to the model, but we cannot tell whether it triggers 0 or 1 prediction
Feature Importance vs. SHAP Importance
SHAP Importance
Feature Importance vs. SHAP Importance
SHAP Importance
SHAP importance averages feature contribution for each row in the dataset
Feature Importance vs. SHAP Importance
SHAP importance averages feature contribution for each row in the dataset
SHAP Importance
They are totally different from XGBoost feature importance!
Feature Importance vs. SHAP Importance
SHAP Importance
They are totally different from XGBoost feature importance!
Tree attribution methods give more value to features far away from the root
Counterintuitive
SHAP importance averages feature contribution for each row in the dataset
Feature Importance vs. SHAP Importance
SHAP can be used to extract local explanations via Force plots
Feature Importance vs. SHAP Importance
SHAP can be used to extract local explanations via Force plots
They tell us how much feature contributed to make the prediction diverge from a base value (average prediction with no features)
Feature Importance vs. SHAP Importance
SHAP can be used to extract local explanations via Force plots
They tell us how much feature contributed to make the prediction diverge from a base value (average prediction with no features)
Low values of `Total Sulfur Dioxide` (mean=30) push the output towards a positive prediction, while `Sulphates` does the opposite
SHAP: Many Visualization Tools
SHAP: Many Visualization Tools
SHAP: Many Visualization Tools
SHAP: Many Visualization Tools
GNN-Explainer
Where we show the first example of an XAI method for GNNs …
Some slides are courtesy of Prof. Simone Scardapane.
AI4BA 2024 - June 26, 2024
AI4BA 2024 - June 26, 2024
GNNs are Powerful but …
AI4BA 2024 - June 26, 2024
GNNExplainer in a Nutshell
AI4BA 2024 - June 26, 2024
GNNExplainer Characteristics
AI4BA 2024 - June 26, 2024
GNNExplainer Characteristics
AI4BA 2024 - June 26, 2024
GNNExplainer: Problem Formulation
AI4BA 2024 - June 26, 2024
GNNExplainer: Problem Formulation
AI4BA 2024 - June 26, 2024
GNNExplainer: Problem Formulation
AI4BA 2024 - June 26, 2024
GNNExplainer: Single-Instance Explanations
AI4BA 2024 - June 26, 2024
This is a constant after the GNN has been trained
GNNExplainer: Single-Instance Explanations
AI4BA 2024 - June 26, 2024
Optimization Framework
AI4BA 2024 - June 26, 2024
Prediction should stay consistent
The mask should be sparse
Weights should be as close as possible to 0 or 1
M=σ(ℳ)�σ is the sigmoid
Experiments: Datasets
AI4BA 2024 - June 26, 2024
Experiments: Qualitative Results
AI4BA 2024 - June 26, 2024
Experiments: Qualitative Results
AI4BA 2024 - June 26, 2024
Experiments: Qualitative Results
AI4BA 2024 - June 26, 2024
Experiments: Qualitative Results
AI4BA 2024 - June 26, 2024
PGExplainer
Where we show a more advanced example of an XAI method for GNNs …
Some slides are courtesy of Prof. Simone Scardapane.
AI4BA 2024 - June 26, 2024
AI4BA 2024 - June 26, 2024
PGExplainer in a Nutshell
AI4BA 2024 - June 26, 2024
PGExplainer Characteristics
AI4BA 2024 - June 26, 2024
PGExplainer Learning Objectives
AI4BA 2024 - June 26, 2024
PGExplainer: Selecting Gs is intractable …
AI4BA 2024 - June 26, 2024
PGExplainer: Reparametrization Trick
AI4BA 2024 - June 26, 2024
PGExplainer: Reparametrization Trick
AI4BA 2024 - June 26, 2024
PGExplainer: Reparametrization Trick
AI4BA 2024 - June 26, 2024
PGExplainer: Experiments
AI4BA 2024 - June 26, 2024
PGExplainer: Experiments
AI4BA 2024 - June 26, 2024
ProtGNN
Where we show a self-explainable method for GNNs …
AI4BA 2024 - June 26, 2024
AI4BA 2024 - June 26, 2024
ProtGNN: Characteristics
AI4BA 2024 - June 26, 2024
ProtGNN: Characteristics
AI4BA 2024 - June 26, 2024
ProtGNN: GNN Encoder
AI4BA 2024 - June 26, 2024
ProtGNN: Prototypes
AI4BA 2024 - June 26, 2024
ProtGNN: Prototype Layer gP
AI4BA 2024 - June 26, 2024
ProtGNN: Fully Connected Layer c
AI4BA 2024 - June 26, 2024
ProtGNN: Learning Objective
AI4BA 2024 - June 26, 2024
ProtGNN: Interpreting Prototypes
AI4BA 2024 - June 26, 2024
ProtGNN++: Conditional Subgraph Sampling
AI4BA 2024 - June 26, 2024
ProtGNN++: Accuracy
AI4BA 2024 - June 26, 2024
ProtGNN++: Anecdotal Examples
AI4BA 2024 - June 26, 2024
ProtGNN++: Anecdotal Examples
AI4BA 2024 - June 26, 2024
Encoding Concepts in Graph Neural Networks
Where we show a self-explainable and concept-based GNN XAI method …
AI4BA 2024 - June 26, 2024
AI4BA 2024 - June 26, 2024
Missione 4 • Istruzione e Ricerca
Missione 4 • Istruzione e Ricerca
AI4BA 2024 - June 26, 2024
Explainable-by-Design Graph Neural Network
Missione 4 • Istruzione e Ricerca
Missione 4 • Istruzione e Ricerca
Highly efficient:
different concepts
AI4BA 2024 - June 26, 2024
Concept Distillation
Missione 4 • Istruzione e Ricerca
Missione 4 • Istruzione e Ricerca
AI4BA 2024 - June 26, 2024
Logic Explained Network
Missione 4 • Istruzione e Ricerca
Missione 4 • Istruzione e Ricerca
AI4BA 2024 - June 26, 2024
Concept-based Logic Explanation
Missione 4 • Istruzione e Ricerca
Missione 4 • Istruzione e Ricerca
AI4BA 2024 - June 26, 2024
Results
Missione 4 • Istruzione e Ricerca
Missione 4 • Istruzione e Ricerca
AI4BA 2024 - June 26, 2024
Concept interventions
Counterfactual Explanations
Where we show what if …
AI4BA 2024 - June 26, 2024
Introduction
AI4BA 2024 - June 26, 2024
Explainable Artificial Intelligence?
https://medium.com/@BonsaiAI/what-do-we-want-from-explainable-ai-5ed12cb36c07
AI4BA 2024 - June 26, 2024
Counterfactual Explanation
f( ) = No
Will I have diabetes?
Yes/No + Explanation
Age | Gender | Exercise Level | Fat Level |
45 | M | Low | High |
f( ) = Yes
Factual
Age | Gender | Exercise Level | Fat Level |
45 | M | Medium | Average |
Counterfactual
Explanation: You will not develop diabetes if you lower your fat level and you increase your exercise level.
AI4BA 2024 - June 26, 2024
Generic Counterfactual Explanation
AI4BA 2024 - June 26, 2024
Notation
AI4BA 2024 - June 26, 2024
Counterfactual Explanations for Classification Models
AI4BA 2024 - June 26, 2024
Counterfactual Explanations for Regression
AI4BA 2024 - June 26, 2024
Optimal Counterfactuals
AI4BA 2024 - June 26, 2024
Picture taken from: https://www.arthur.ai/blog/counterfactual-explainability-neurips
Optimal Counterfactuals
AI4BA 2024 - June 26, 2024
Metrics for CF Explanations
AI4BA 2024 - June 26, 2024
Metrics
See Sahil Verma, John Dickerson, and Keegan Hines. 2020. Counterfactual Explanations for Machine Learning: A Review. arXiv preprint arXiv:2010.10596 (2020) for a thorough explanation of the metrics
AI4BA 2024 - June 26, 2024
Validity
Validity: 4/9
AI4BA 2024 - June 26, 2024
Proximity
d( , ) = 1/n
AI4BA 2024 - June 26, 2024
Sparsity
Sparsity( , ) = 1
AI4BA 2024 - June 26, 2024
Generation Time
AI4BA 2024 - June 26, 2024
Generating Actionable Interpretations from Ensembles of Decision Trees
Tolomei & Silvestri. Generating Actionable Interpretations from Ensembles of Decision Trees. IEEE Transactions on Knowledge and Data Engineering. 2021.
Slides mostly based on:
Tolomei et al. Interpretable predictions of tree-based ensembles via actionable feature tweaking. Proceedings of the 23rd ACM SIGKDD international conference on knowledge discovery and data mining. 2017.��Patent Application:�Tolomei, G., Haines, A., Lalmas, M., & Silvestri, F. (2018). U.S. Patent Application No. 15/444,912.
AI4BA 2024 - June 26, 2024
Predictive Models as Black Boxes
AI4BA 2024 - June 26, 2024
Let’s Open the Black Box
AI4BA 2024 - June 26, 2024
Random Forest Models
AI4BA 2024 - June 26, 2024
Random Forest Models
AI4BA 2024 - June 26, 2024
… A Bunch of Trees in The Black Box :)
AI4BA 2024 - June 26, 2024
… A Bunch of Trees in The Black Box :)
AI4BA 2024 - June 26, 2024
Preliminaries
AI4BA 2024 - June 26, 2024
Preliminaries
AI4BA 2024 - June 26, 2024
Problem Definition
AI4BA 2024 - June 26, 2024
𝛿 is a, sort of, proximity value
Positive vs. Negative Paths
AI4BA 2024 - June 26, 2024
Positive vs. Negative Paths
We can skip all the trees containing the positive paths, as these are already encoding the (positive) prediction we ultimately want.
AI4BA 2024 - June 26, 2024
Positive vs. Negative Paths
AI4BA 2024 - June 26, 2024
Building ε-satisfactory Instances
AI4BA 2024 - June 26, 2024
Finding a Valid Tweaking
NP-Hard. Reduction to DNF-MAXSAT
AI4BA 2024 - June 26, 2024
Experiments
AI4BA 2024 - June 26, 2024
Ad Quality Experiments
AI4BA 2024 - June 26, 2024
Ads Features
AI4BA 2024 - June 26, 2024
Ads Quality Classifiers
AI4BA 2024 - June 26, 2024
Qualitative Evaluation
AI4BA 2024 - June 26, 2024
Feature Importance
AI4BA 2024 - June 26, 2024
Feature Helpfulness (Importance for Actionability)
AI4BA 2024 - June 26, 2024
Impact of ε
AI4BA 2024 - June 26, 2024
Impact of ε on cost 𝛿
AI4BA 2024 - June 26, 2024
ReLAX: Reinforcement Learning Agent Explainer for Arbitrary Predictive Models
Slides mostly based on:
AI4BA 2024 - June 26, 2024
The Idea
0.2
blue
20
red
Model
AI4BA 2024 - June 26, 2024
The Idea
0.2
blue
20
red
Model
AI4BA 2024 - June 26, 2024
The Idea
0.2
blue
20
red
Model
-1
AI4BA 2024 - June 26, 2024
The Idea
0.2
blue
20
red
Agent
Model
AI4BA 2024 - June 26, 2024
The Idea
0.2
blue
20
red
Agent
Model
AI4BA 2024 - June 26, 2024
The Idea
0.7
blue
20
red
Agent
Model
AI4BA 2024 - June 26, 2024
The Idea
0.7
blue
20
red
Agent
Model
AI4BA 2024 - June 26, 2024
The Idea
Agent
Model
0.7
blue
20
red
AI4BA 2024 - June 26, 2024
The Idea
Agent
Model
0.7
blue
20
red
-1
AI4BA 2024 - June 26, 2024
The Idea
0.7
blue
20
red
Agent
Model
AI4BA 2024 - June 26, 2024
The Idea
0.7
blue
20
red
Agent
Model
AI4BA 2024 - June 26, 2024
The Idea
0.7
blue
5
red
Agent
Model
AI4BA 2024 - June 26, 2024
The Idea
0.7
blue
5
red
Agent
Model
AI4BA 2024 - June 26, 2024
The Idea
Agent
Model
0.7
blue
5
red
AI4BA 2024 - June 26, 2024
The Idea
Agent
Model
0.7
blue
5
red
+1
AI4BA 2024 - June 26, 2024
The Counterfactual x̃
0.7
blue
5
red
AI4BA 2024 - June 26, 2024
Markov Decision Process Formulation
AI4BA 2024 - June 26, 2024
Overview of our proposed ReLAX framework
AI4BA 2024 - June 26, 2024
Who Explains the Explainer
AI4BA 2024 - June 26, 2024
Experiments: The Datasets
AI4BA 2024 - June 26, 2024
Experiments: The (Black Box) Model Used
AI4BA 2024 - June 26, 2024
Experiments Sparsity vs. Validity
AI4BA 2024 - June 26, 2024
Validity measures the ratio of CFs that actually meet the prediction goal to the total number of CFs generated.
Sparsity measures the number of features changed
Sparsity vs. Validity: The Case of Boston Housing
As this is a regression task we rely on the concept of validity threshold 𝛿 (|ℎ𝝎(x̃) − ℎ𝝎(x)| ≥ 𝛿). The higher 𝛿 the more difficult for the model to find a valid CF example
AI4BA 2024 - June 26, 2024
Proximity and Generation Time
AI4BA 2024 - June 26, 2024
Impact of the “Black Box”
AI4BA 2024 - June 26, 2024
Effect of λ (The Importance of Proximity)
AI4BA 2024 - June 26, 2024
A Case Study: COVID19 Mortality
AI4BA 2024 - June 26, 2024
Graph Convolutional Neural Networks
AI4BA 2024 - June 26, 2024
Why Convolutional
AI4BA 2024 - June 26, 2024
Example GCN Layer
ne[n] == neighbors of node n
AI4BA 2024 - June 26, 2024
Example GCN Layer
AI4BA 2024 - June 26, 2024
Example: Graph Classification with GCN
AI4BA 2024 - June 26, 2024
Example: Graph Classification with GCN
It aggregates embedding by averaging them and weighting them (avgpool).
AI4BA 2024 - June 26, 2024
CF-GNNExplainer: Counterfactual Explanations for Graph Neural Networks
Slides mostly based on:
AI4BA 2024 - June 26, 2024
Graph Neural Networks for Node Classification
Curtesy of http://snap.stanford.edu/proj/embeddings-www/files/nrltutorial-part2-gnns.pdf
AI4BA 2024 - June 26, 2024
CF-Example for Graph NNs
AI4BA 2024 - June 26, 2024
Counterfactual Explanations for Node Prediction
Matrix sparsification
original
Counterfactual model
AI4BA 2024 - June 26, 2024
Adjacency Matrix Perturbation
AI4BA 2024 - June 26, 2024
An example for GCN
AI4BA 2024 - June 26, 2024
CF-GNNExplainer
AI4BA 2024 - June 26, 2024
Experiments
AI4BA 2024 - June 26, 2024
Datasets
AI4BA 2024 - June 26, 2024
Datasets Statistics
AI4BA 2024 - June 26, 2024
Experiments: Metrics
AI4BA 2024 - June 26, 2024
Experiments: Results
AI4BA 2024 - June 26, 2024
Experiments: Explanation Size
AI4BA 2024 - June 26, 2024
Experiments: Explanation Size
AI4BA 2024 - June 26, 2024
GNNExplainer (Not Counterfactual)
AI4BA 2024 - June 26, 2024
GNNExplainer (Not Counterfactual)
GNNEXPLAINER generates an explanation by identifying a small subgraph of the input graph together with a small subset of node features (shown on the right) that are most influential for ŷi. Examining explanation for ŷi, we see that many friends in one part of vi’s social circle enjoy ball games, and so the GNN predicts that vi will like basketball. Similarly, examining explanation for ŷj , we see that vj’s friends and friends of his friends enjoy water and beach sports, and so the GNN predicts ŷj = “Sailing.”
AI4BA 2024 - June 26, 2024
Experiments: Against GNNExplainer
AI4BA 2024 - June 26, 2024
More Information on Counterfactual GNN Explainers
AI4BA 2024 - June 26, 2024
More Information on Counterfactual GNN Explainers
AI4BA 2024 - June 26, 2024
All Good Things Must Come To An End
AI4BA 2024 - June 26, 2024
One Last Thing
Where we show that XAI can even be used adversarially …
AI4BA 2024 - June 26, 2024
The Impact of Source-Target Node Distance on Vicious Adversarial Attacks in Social Network Recommendation Systems
Giovanni Trappolini, Federico Albanese, Lorenzo Scarlitti, Fabrizio Silvestri
OUTLINE
[1] Trappolini, G., Maiorca, V., Severino, S., Rodola, E., Silvestri, F., & Tolomei, G. (2023). Sparse vicious attacks on graph neural networks. IEEE Transactions on Artificial Intelligence. https://ieeexplore.ieee.org/abstract/document/10264111
AI4BA 2024 - June 26, 2024
GOAL
Adversarial Attacks → on what?
AI4BA 2024 - June 26, 2024
TASK: LINK PREDICTION
AI4BA 2024 - June 26, 2024
TASK: LINK PREDICTION
AI4BA 2024 - June 26, 2024
TASK: LINK PREDICTION
A malicious node “s” attacks target user “t”
AI4BA 2024 - June 26, 2024
BEFORE…
Before analyzing how we mount this attack we’ll analyze some common “pitfalls” in the state of the art.
AI4BA 2024 - June 26, 2024
CHOICE OF USERS
Some methods assume the attacker can control a subset of the users of the network that already exist.
AI4BA 2024 - June 26, 2024
VICIOUS USERS
AI4BA 2024 - June 26, 2024
VICIOUS USERS
Disproportionate use of vicious nodes, Budgeted
AI4BA 2024 - June 26, 2024
BACKGROUND
2 Steps:
AI4BA 2024 - June 26, 2024
PROPOSED METHOD
Sparse Attacks: we employ a significant smaller number of malicious users to mount the attack → akin to sparse regression
AI4BA 2024 - June 26, 2024
HOW?
To achieve this we use a set of 3 losses:
AI4BA 2024 - June 26, 2024
HOW?
AI4BA 2024 - June 26, 2024
1.
I.e. the attack must be successful, the link prediction systems must detect the link.
AI4BA 2024 - June 26, 2024
2.
AI4BA 2024 - June 26, 2024
2.
AI4BA 2024 - June 26, 2024
RESULTS (I)
AI4BA 2024 - June 26, 2024
IMPORTANT OPEN PROBLEMS
AI4BA 2024 - June 26, 2024
IMPORTANT OPEN PROBLEMS
AI4BA 2024 - June 26, 2024
RESULTS - Effectiveness
AI4BA 2024 - June 26, 2024
RESULTS - Efficiency
AI4BA 2024 - June 26, 2024
This is The End
AI4BA 2024 - June 26, 2024