liveBook · Manning

Preprocessing

As explained in Graph Neural Networks in Action

Data preprocessing is the transformation and preparation of data into a form suitable for model training or inference.

Preprocessing transforms raw data into a graph-aware form suitable for GNN training and inference. It connects graph construction with model execution by organizing representations, splits, and data loading. section 1.5.1 section 7.2

A practical preprocessing pipeline typically includes:

  • Choose nodes, edges, features, and a storage representation for the raw data. section 1.5.1
  • Represent graph structure with an adjacency list, adjacency matrix, edge list, or subgraph. section 8.3
  • Split examples into training, validation, and test subsets, often using Boolean masks or index arrays. section 1.5.1 section 8.3
  • Sample or batch data when the graph or dataset cannot be processed efficiently as one whole input. section 1.5.1 section 4.3.2

Converting a graph for GNN training

A representative workflow creates train/test indices, converts a NetworkX graph into a PyTorch Geometric data object, assigns feature and label tensors, and applies the indices to the converted data. A GCN can then consume the complete graph during forward propagation while using a training mask to calculate loss. 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

Follow the end-to-end mental model from raw data through graph representation, exploration, and preprocessing for model training. section 1.5.1

Figure 8.7 Summary of steps in the data pipeline process in this section
figure

Use the pipeline summary to inspect how problem-specific data and storage choices become a preprocessed dataset. section 8.3

How Graph Neural Networks in Action covers it

How deep it goes
Defines graph conversion, splitting, sampling, and batching, while deferring deeper preprocessing detail to appendix B.
Examples
Demonstrates NetworkX-to-PyG conversion, tensor assignment, indexed splits, masks, and full-graph or batched model input.
What it assumes
Assumes raw data and graph-structure decisions, while defining masks and representations such as edge lists and adjacency lists.
What you can do after
Apply preprocessing via PyTorch Geometric and NetworkX to produce graph data suitable for GNN training.
How it connects
Connects graph representation, masks, train/test splitting, batching, sampling, GNN training, and inference.

Also explained in

Compare how 22 books explain preprocessing →

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.