shapiq.graph

GraphSHAP-IQ: exact Shapley interactions of the nodes of graph neural networks.

The embedding of a node after L message passing layers depends only on the nodes within L hops, its receptive field. GraphSHAPIQ exploits this for any game whose players are the nodes of a graph: it evaluates the game only on subsets of the receptive fields and computes the exact interactions from their Möbius coefficients [Muschalik et al., 2025].

  • GraphModel is the internal representation of a graph: its edges, nodes, node features, and the radius of the receptive fields. convert_graph() builds it from a graph of torch_geometric.

  • GraphBaselineImputer is the BaselineImputer of a graph: its players are the nodes, and absent nodes take the baseline node features. It calls the model as a function of node features, which get_graph_predict_function() makes of a torch model.

  • GraphSHAPIQ computes the interactions of a game that is local on a graph.

  • GraphExplainer explains the graph-level output of a graph neural network with them.

Graphs and models of torch_geometric require torch and torch_geometric, which the graph extra installs: pip install 'shapiq[graph]'. The rest needs neither.

Classes

GraphBaselineImputer

The BaselineImputer of a graph, whose players are its nodes.

GraphModel

A graph as a graph neural network with n_hops message passing layers sees it.

GraphPredictFunction

A model as a function of the node features of masked copies of one graph.

GraphSHAPIQ

GraphSHAP-IQ computes the exact Shapley interactions of games that are local on a graph.

Functions

convert_graph

Convert a graph into a GraphModel.

get_graph_predict_function

Return the model as a function of the node features of masked copies of the graph.