"An accurate forecast a control-room operator will not act on is a research demo. Show me which three sensors and which two hours drove the alarm, and now it is a tool."
An Accountable AI Agent
Prerequisites
This section builds on the message-passing skeleton and the meaning of an edge from Section 54.1, the spatiotemporal architectures (DCRNN, Graph WaveNet) of Section 54.3, and the fault-localization framing of Section 54.4. It leans on the general interpretability vocabulary (saliency, attribution, faithfulness) developed for time series in Chapter 67, and on the leakage-safe evaluation habits of Chapter 5. Gradients through a network come from the Deep Learning Refresher in Appendix B.
The Big Picture
A graph neural network on a sensor network makes predictions by mixing signals across a specific set of relationships. That is its strength and, for a human, its problem: the answer is a function of hundreds of nodes, thousands of edges, and a rolling window of time, blended through several layers of nonlinear aggregation. When such a model raises an alarm on a power grid or forecasts congestion on a highway, an operator cannot act on a scalar. They need to know which sensors, which couplings, and which moments the model used, and whether those match physical reality. Interpretability for sensor GNNs is the discipline of turning an opaque prediction into a small, faithful, testable story told in the model's own native vocabulary: a subgraph of nodes and edges, a mask over features, a slice of the time window. Unlike a heatmap over an image, a GNN explanation lands on objects an engineer already understands, a transmission line, a pipe, a road segment, which is what makes it actionable, and what makes it dangerous when it is wrong.
What there is to explain, and why it is different here
An image classifier explains itself with a saliency map over pixels; a sequence model highlights time steps. A sensor GNN has three attribution surfaces at once, and a useful explanation names all three. First, node importance: which sensors' current features drove this output. Second, edge importance: which relationships carried the decisive messages, since the model's whole premise is that information flows along edges. Third, temporal and feature importance: for the spatiotemporal models of Section 54.3, which time steps and which input channels mattered. The why this matters is not abstract. In a regulated setting (grid operations, water safety, clinical monitoring) an unexplained automated decision is often not permitted; Chapter 70 takes up the legal side. Even without a regulator, an explanation is how you debug the graph: if the model attributes a burst-detection to an edge that does not correspond to a real pipe, you have caught either a bad topology or a spurious correlation before it fails in production.
Key Insight: the explanation is a subgraph, so it is checkable against physics
Because a GNN reasons over nodes and edges that map to real objects, its explanation can be validated against a ground truth an image explanation never has: the physics of the system. If the model says a fault at bus 14 was diagnosed through the transmission lines to buses 9 and 11, an engineer can check whether those lines actually carry the fault current. This is the rare case where an explanation is falsifiable. A congestion forecast whose explanatory subgraph runs backward against one-way flow, or a leak alarm that ignores the trunk main and fixates on an isolated lateral, is telling you the model learned a coincidence, not the mechanism. The explanation's agreement with known conservation and connectivity is itself an evaluation metric, and one you should compute on held-out events under the leakage discipline of Chapter 5.
Three families of method
The how splits into three approaches with different costs and different failure modes. Attention weights are the cheapest: a graph attention network (GAT) already computes a learned coefficient \(\alpha_{ij}\) for each edge, and reading them off looks like an explanation for free. It sometimes is, but attention is a soft routing weight, not a guaranteed attribution; the same output can often be produced by very different attention patterns, so treat attention as a hypothesis to be verified, never as a certificate. Gradient and perturbation attribution ports the tools of Chapter 67 to the graph: integrated gradients over node features, or occlusion, where you zero a node or cut an edge and measure how much the prediction moves. Learned explanation masks are the GNN-specific frontier. GNNExplainer optimizes a continuous mask \(\mathbf{M} \in [0,1]^{|E|}\) over edges (and optionally over features) to find the smallest subgraph that preserves the model's prediction, by maximizing the mutual information between the masked-graph output and the original,
\[ \max_{\mathbf{M}}\; \mathrm{MI}\big(Y,\, (\mathbf{X}, \mathbf{A}\odot\sigma(\mathbf{M}))\big) \;-\; \lambda\,\lVert \mathbf{M} \rVert_1, \]where the \(\ell_1\) penalty forces sparsity so the answer is a handful of edges a human can read, not a diffuse cloud. PGExplainer trains a small network to predict such masks, so once trained it explains new instances in a single forward pass instead of a per-instance optimization, which is what you need to explain a live fleet.
import torch
from torch_geometric.explain import Explainer, GNNExplainer
# `model` is a trained GNN; `data` holds x, edge_index for one sensor-network snapshot.
explainer = Explainer(
model=model,
algorithm=GNNExplainer(epochs=200, lr=0.01),
explanation_type="model", # explain what the model does, not the label
node_mask_type="attributes", # which input features matter
edge_mask_type="object", # which edges (relationships) matter
model_config=dict(mode="regression", task_level="node", return_type="raw"),
)
expl = explainer(data.x, data.edge_index, index=14) # explain the alarm at node 14
edge_score = expl.edge_mask # one importance in [0,1] per edge
top = edge_score.topk(3).indices # the 3 decisive relationships
print("decisive edges:", data.edge_index[:, top].t().tolist())
print("feature importance:", expl.node_mask[14].round(decimals=2).tolist())
Explainer wrapper around GNNExplainer. The returned edge_mask ranks every relationship by how much removing it would change the prediction at node 14; the top few edges are the subgraph you hand to an operator, and node_mask tells you which input channels on that node carried the signal.Listing 54.7 makes the abstract mask concrete: the output is not a scalar confidence but the three edges and the feature channels the model actually used, expressed as objects an engineer can trace on a schematic.
Right Tool: torch_geometric.explain unifies the whole family
Implementing GNNExplainer from scratch (the masked forward pass, the mutual-information objective, the entropy and sparsity regularizers, the per-instance optimization loop) is roughly 200 to 300 lines, and a faithful gradient attribution through sparse message passing is another 100. The torch_geometric.explain package collapses all of it to the dozen lines of Listing 54.7, and swapping GNNExplainer for PGExplainer, AttentionExplainer, or an integrated-gradients attribution is a one-word change to the algorithm argument. The same Explainer object also ships faithfulness metrics (fidelity and characterization score) through torch_geometric.explain.metric, so you evaluate an explanation with one more call rather than reimplementing the protocol.
Is the explanation faithful? Measuring, not trusting
An explanation that looks plausible can still be unfaithful, describing what a human expects rather than what the model computed. So you measure faithfulness with a perturbation protocol. Fidelity-minus asks how much the prediction degrades when you keep only the explanatory subgraph and drop the rest; a faithful explanation loses little. Fidelity-plus asks how much it degrades when you remove exactly the explanatory subgraph and keep everything else; a faithful, decisive explanation loses a lot. Sparsity counts the edges retained, because an "explanation" that keeps half the graph explains nothing. A good method pushes fidelity-plus high and the retained set small at once. Two cautions carry over from the rest of the book. First, attention magnitude is not attribution: a heavily attended edge that, when cut, barely moves the output was not actually decisive, and only the perturbation test reveals that. Second, evaluate explanations on held-out events, never on the events the mask was fit to, or you measure memorization, exactly the leakage failure mode of Chapter 5.
Practical Example: an explained alarm in a transmission-grid control room
A transmission operator runs a spatiotemporal GNN over 2,000 phasor measurement units to flag developing instability. The first deployment failed a human trial: the model was accurate, but dispatchers would not trust a red light with no reason, and a false alarm costs a needless load-shed. The team added GNNExplainer-style edge masks to every alert. Now a flagged oscillation arrives as a three-line story: nodes 812, 47, and 903, coupled through two specific 500 kV lines, over the last 90 seconds. A dispatcher recognizes that corridor instantly and confirms or dismisses in seconds. The explanation also caught a bug the accuracy metric had hidden: on a subset of alarms the decisive edge was a retired line still present in the stale topology file, so the model was routing through a relationship that no longer existed physically. Fixing the graph removed a class of false alarms that no aggregate error number had localized. This is the fault-attribution goal of Section 54.4 made auditable, and it connects directly to the condition-monitoring practice of Chapter 37.
Reading the learned graph itself
A distinct opportunity, unique to the adaptive models of Section 54.3, is that some GNNs learn their adjacency. Graph WaveNet's self-adaptive adjacency matrix is, after training, a dense map of which sensors the model decided are coupled, learned from data rather than handed a topology. Inspecting it is a form of global interpretability: strong learned edges that match the known physical network are reassuring, and strong edges that do not are hypotheses about hidden couplings (a shared upstream disturbance, an unmodeled electrical path) worth investigating. The same caution from structure learning applies: a learned edge that improves prediction need not be a causal wire, since many adjacencies explain the same data equally well. Read the learned graph as a source of testable hypotheses, then confirm the important ones with an intervention or a perturbation test, not as a discovered ground truth.
Research Frontier: from correlational subgraphs to causal, self-explaining GNNs
The current frontier attacks the gap that GNNExplainer and PGExplainer leave open: their subgraphs are correlational, so they can latch onto a spurious edge that predicts well in-distribution and fails under shift, the concern of Chapter 66. Three directions lead. Causal explanation methods (CF-GNNExplainer and counterfactual masks) ask for the smallest edge change that flips the prediction, which is closer to an actionable intervention than a preserving subgraph. Self-explaining architectures (prototype and information-bottleneck GNNs such as ProtGNN and GSAT) build the sparse explanatory subgraph into the forward pass, so the model cannot use edges it did not surface. Standardized faithfulness evaluation (the GraphXAI benchmark of Agarwal and colleagues) supplies graphs with ground-truth explanations so competing methods can be scored rather than eyeballed. For safety-critical sensor networks the target is an explanation that is faithful, causal, and stable under the distribution shift a deployed fleet actually sees, a bar no method fully clears in 2026.
Exercise
Train a two-layer graph-convolution model on the METR-LA traffic network for one-step speed prediction. (1) For ten congestion events, run GNNExplainer to extract the top-5 edge mask per event, and compute fidelity-plus (drop those edges, measure the prediction change) and fidelity-minus (keep only those edges). Report both against a random-edge baseline of the same size. (2) Overlay the explanatory edges on the road map: what fraction follow a real road segment versus a purely statistical correlation edge? (3) Repeat the fidelity computation on events the mask was not fit on and explain any gap in terms of the leakage principle of Chapter 5.
Self-Check
1. Name the three attribution surfaces a sensor GNN exposes, and give a one-line example of a question each one answers. 2. Why is attention weight not a reliable explanation, and what perturbation test would you run to check whether a highly attended edge was actually decisive? 3. Define fidelity-plus and fidelity-minus, and explain why a good explanation should have high fidelity-plus and low retained-edge count at the same time.
Lab 54
build a spatiotemporal GNN for sensor-network forecasting or anomaly localization (METR-LA/PEMS-BAY).
What's Next
In Chapter 55, the falsifiable explanations of this section meet their natural ally: physics. Digital twins and physics-informed models give the sensor network a simulated ground truth to check learned couplings against, and constrain the model so its explanations respect conservation laws by construction rather than by luck.
Bibliography
GNN explanation methods
The founding method: optimize a sparse edge-and-feature mask that maximizes mutual information with the prediction. The subgraph objective and the PyG wrapper of Listing 54.7 come from here.
Trains a network to predict edge masks, giving amortized, single-pass explanations across instances, the version you need to explain a live sensor fleet rather than one snapshot.
Explains a GNN with an interpretable probabilistic graphical model over the important nodes, capturing dependencies a flat importance score misses.
Attention, attribution, and their limits
Velickovic, Cucurull, Casanova, Romero, Lio & Bengio (2018). Graph Attention Networks. ICLR.
Introduces learned per-edge attention coefficients, the cheapest and most tempting "free" explanation for a sensor GNN, and the one this section warns must be verified.
Jain & Wallace (2019). Attention is not Explanation. NAACL.
Shows that very different attention distributions yield the same prediction, so attention weight is not a faithful attribution. The direct justification for the perturbation-test caution here.
The gradient-attribution method ported to node features here; its completeness axiom is why integrated gradients is preferred over raw saliency for feature importance.
Surveys, benchmarks, and spatiotemporal models
Yuan, Yu, Gui & Ji (2022). Explainability in Graph Neural Networks: A Taxonomic Survey. IEEE TPAMI.
Organizes the whole field into instance-level and model-level methods and defines the fidelity and sparsity metrics used in this section's faithfulness protocol.
Provides graphs with ground-truth explanations and a scoring harness, moving explanation evaluation from eyeballing to measurement; the benchmark named in the research-frontier callout.
Wu, Pan, Long, Jiang & Zhang (2019). Graph WaveNet for Deep Spatial-Temporal Graph Modeling. IJCAI.
Its self-adaptive adjacency matrix is the learned graph this section reads as a global interpretability artifact, and the source of hidden-coupling hypotheses.