PyTorch Geometric (PyG) supplies graph data structures and neural-network components for building GNN systems in PyTorch. A typical workflow preprocesses graph data, packages node features, edges, and labels into a Data object, applies masks, and trains a task-specific model. section 12.1.3 section 12.0
A practical PyG pipeline includes:
- Create a Data object with x for node features, edge_index for graph connectivity, and y for node labels. section 12.1.3
- Expose only known labels through a mask, randomly partition eligible nodes, and attach train_mask, val_mask, and test_mask to the graph. section 12.1.3
- Build node-classification or link-prediction models with GNN encoders, including GCN, GraphSAGE, and GAT variants. section 12.0 section 12.2.4
- Handle heterogeneous graphs by converting a homogeneous base model with to_hetero() and supplying metadata describing node and edge types. section 12.2.4
Fraud detection and recommendations
For financial transactions, PyG supports node classification into licit and illicit classes. For movie recommendations, user and movie embeddings pass through a heterogeneous GNN, and a dot product scores likely user–movie links. section 12.1.3 section 12.2.4
Figure 12.3 Overview of data processing applied to the Elliptic dataset. Source data is preprocessed to create node features, edge indices, and encoded labels. These tensors are incorporated into a PyG Data object, where a node masking approach partitions the nodes into training (80%), validation (10%), and testing (10%) sets.
Trace preprocessing into a PyG Data object and see how node masks create training, validation, and testing partitions. section 12.1.3

