liveBook · Manning

Chapter 12: Node classification and link prediction with GNNs

What you will learn in chapter 12 of Knowledge Graphs and LLMs in Action

The introduction connects two GNN tasks to real-world applications: identifying illicit activity in transaction graphs and recommending movies from user–movie interactions.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction connects two GNN tasks to real-world applications: identifying illicit activity in transaction graphs and recommending movies from user–movie interactions.

Key terms: node classification, anti-money laundering (AML), licit or illicit, link prediction, user–movie interactions, ratings, embeddings

12.1 Node classification for anti-money laundering applications

Introduces anti-money laundering node classification by representing financial transactions as a graph and using GNNs to identify licit and illicit nodes.

Key terms: AML, node classification, GNNs, licit and illicit nodes, Elliptic dataset

12.1.1 Input data

Introduces the Elliptic financial-transaction dataset and identifies the files that supply nodes, directed edges, features, and class labels for the GNN example.

Key terms: Elliptic dataset, features, edges, classes, directed payment flows

12.1.2 Graph processor: Data preparation

This section prepares financial transaction edges, node features, and labels as aligned numerical tensors for GNN learning.

Key terms: txId1, txId2, incremental ID, edge_index, node_features, node features, LabelEncoder, node_labels, licit, illicit

12.1.3 Graph processor: Homogeneous PyG graph

The section turns preprocessed Elliptic data into a homogeneous PyG graph and defines labeled-node splits for node classification.

Key terms: PyG Data object, node_features, edge_index, node_labels, known_mask, valid nodes, known labels, licit, illicit, training mask

12.1.4 Encoder–decoder architecture

This section shows how a homogeneous GNN encoder and a classification decoder are assembled for anti-money laundering node classification.

Key terms: NodeClassifier, encoder, decoder, node representation, licit, illicit, homogeneous GNN, base graph model, SAGEConv, GATConv

12.1.5 Evaluation and analysis

Compares GCN, GAT, and SAGE for AML node classification using training cost, validation metrics, and test-set confusion matrices to explain why SAGE is the preferred model.

Key terms: GCN, GAT, SAGE, attention mechanism, learning parameters, training time, precision, recall, F1-score, weighted average

12.2 Link prediction for movie recommendations

This section frames movie recommendations as a graph link-prediction problem in which links represent interactions and preferences between users and movies.

Key terms: link prediction, interactions, preferences, user–movie links

12.2.1 Input data

Identifies the MovieLens input columns used for the movie-recommendation link prediction task.

Key terms: MovieLens, movies.csv, ratings.csv, movieId, userId, genres

12.2.2 Graph processor: Data preparation

This section prepares movie genre features and user–movie rating connections as numerical inputs for a PyG graph.

Key terms: genre information, vector of features, movie_feat, edge_index tensor, ID mappings, ratings

12.2.3 Graph processor: Heterogeneous PyG graph

This section builds a heterogeneous PyG graph for movie link prediction, separates edges for message passing and evaluation, and prepares sampled mini-batches.

Key terms: HeteroData, Data, users, movies, rates, edge_index, reverse edges, message passing, rev_edge_types, RandomLinkSplit

12.2.4 Encoder–decoder architecture

Explains how a heterogeneous GNN encoder creates user and movie representations and how a dot-product decoder uses them for movie link prediction.

Key terms: embedding matrix, user_input_dim, out_dim, movie genres, heterogeneous GNN, to_hetero(), metadata, HeteroData, neighborhood’s feature aggregation, decoder

12.2.5 Evaluation and analysis

The section compares the efficiency and recommendation performance of GCN, GAT, and SAGE link-prediction models using validation metrics and test-set confusion matrices.

Key terms: SAGE, GAT, GCN, embedding layer, heterogeneous GNN models, parameters, precision, recall, F1-score, user–movie links

12.3 Summary

Concepts explained in this chapter

← Chapter 11: Graph representation learning and graph neural networks Chapter 13: Knowledge graph–powered retrieval-augmented generation →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.