shapiq_benchmark.setups.GraphSetup¶
- class shapiq_benchmark.setups.GraphSetup(*, dataset='MUTAG', model='gcn', n_layers=2, hidden_size=32, n_epochs=100, learning_rate=0.01, x=0, class_index=None, baseline='zeros', test_size=0.2, random_state=42, normalize=True, batch_size=128)[source]¶
Bases:
SetupA
GraphGameof a graph neural network trained on a graph dataset.The network has
n_layersmessage passing layers of themodelwith ReLU, a mean over the nodes, and a linear readout of the class logits, so its game is local on the graph andGraphComputercomputes its exact values with GraphSHAP-IQ. It is trained with Adam on the training split of the dataset (fromload_graph_dataset(), stratified); the explained graph is taken from the test split.- Variables:
dataset – The graph dataset. Defaults to
"MUTAG".model – The message passing layers,
"gcn"(default),"gin", or"gat".n_layers – The number of message passing layers, the radius of the receptive fields. Defaults to
2.hidden_size – The size of the node embeddings. Defaults to
32.n_epochs – The number of training epochs. Defaults to
100.learning_rate – The learning rate of Adam. Defaults to
0.01.x – The index of the explained graph in the test split. Defaults to
0.class_index – The explained class (
Nonemeans class1).baseline – The node features of absent nodes,
"zeros"(default) or the"mean"node features of the training graphs.test_size – The fraction of the graphs in the test split. Defaults to
0.2.random_state – The seed of the split, the initialization, and the training.
normalize – Whether to center the game. Defaults to
True.batch_size – The number of masked graphs per forward pass (a runtime field).
Examples
>>> setup = GraphSetup(dataset="MUTAG", model="gin", x=3) >>> game = setup.build()
- to_dict()¶
Return the setup as a JSON-serializable dictionary (the inverse of
setup_from_dict()).
- baseline = 'zeros'¶
- batch_size = 128¶
- class_index = None¶
- dataset = 'MUTAG'¶
- property key¶
A stable identifier of the game this setup builds, used as its cache key.
It is a digest of the setup’s name,
version,RECIPE_VERSION, and fields (runtime fields excluded), so it is the same across processes and machines.
- learning_rate = 0.01¶
- model = 'gcn'¶
- n_epochs = 100¶
- n_layers = 2¶
- name = 'graph'¶
The registered name of the setup.
- normalize = True¶
- random_state = 42¶
- test_size = 0.2¶
- x = 0¶