liveBook · Manning

Dataset split

As explained in Graph Neural Networks in Action

A partition of a dataset into training and testing subsets for model fitting and evaluation.

A dataset split partitions labeled data into subsets used for fitting and evaluating a model. In graph machine learning, preprocessing commonly creates training, validation, and test sets before model training and inference. section 1.5.1 section 4.3.2

A practical graph-modeling workflow is:

  • Create the split and retain the resulting sample or node indices. section 4.3.2
  • Convert graph data into PyTorch Geometric tensors or a data object. section 4.3.2
  • Apply the same indices to the converted graph data, preserving correspondence between features, labels, and nodes. section 4.3.2
  • Use the training subset for loss calculation while passing the full graph through a GNN when message passing requires its relationships. section 4.3.2

A 20% test split

Set split = 0.2, generate indices for all samples, and call train_test_split with stratify=labels, test_size=split, and random_state=99. Convert the graph with NetworkX and from_networkx, then assign the retained indices to the PyG data object. section 4.3.2

Figure 1.14 Mental model of the GNN project. We start with raw data, which is transformed into a graph data model that can be stored in a graph database or used in a graph processing system. From the graph processing system (and some graph databases), exploratory data analysis and visualization can be done. Finally, for graph machine learning, data is preprocessed into a form that can be submitted for training.
figure

Trace where dataset splitting fits: raw data becomes a graph, preprocessing prepares it for training and inference, and the resulting data feeds graph machine-learning models. section 1.5.1

How Graph Neural Networks in Action covers it

How deep it goes
Explains split creation, index preservation, graph conversion, and mask-based training, but not statistical split theory.
Examples
Demonstrates a stratified 20% split with retained indices, NetworkX conversion, PyTorch Geometric tensors, and a GCN pipeline.
What it assumes
Assumes labeled features and graph structure while introducing preprocessing, index alignment, and graph-specific training behavior.
What you can do after
Apply it via train_test_split and PyTorch Geometric to prepare graph data and restrict training loss to selected nodes.
How it connects
Connects dataset splitting with data preprocessing, batching, sampling, inference, graph neural networks, and training masks.

Also explained in

Compare how 21 books explain dataset split →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.