- class NodePropertySplit(property_name: str, ratios: List[float], ascending: bool = True)
Creates a node-level split with distributional shift based on a given node property, as proposed in the “Evaluating Robustness and Uncertainty of Graph Models Under Structural Distributional Shifts” paper (functional name:
It splits the nodes in a given graph into five non-intersecting parts based on their structural properties. This can be used for transductive node prediction tasks with distributional shifts. It considers the in-distribution (ID) and out-of-distribution (OOD) subsets of nodes. The ID subset includes training, validation and testing parts, while the OOD subset includes validation and testing parts. As a result, it creates five associated node mask vectors for each graph, three which are for the ID nodes (
id_test_mask), and two which are for the OOD nodes (
This class implements three particular strategies for inducing distributional shifts in a graph — based on popularity, locality or density.
property_name (str) – The name of the node property to be used (
ratios ([float]) – A list of five ratio values for ID training, ID validation, ID test, OOD validation and OOD test parts. The values must sum to
from torch_geometric.transforms import NodePropertySplit from torch_geometric.datasets.graph_generator import ERGraph data = ERGraph(num_nodes=1000, edge_prob=0.4)() property_name = 'popularity' ratios = [0.3, 0.1, 0.1, 0.3, 0.2] tranaform = NodePropertySplit(property_name, ratios) data = transform(data)