liveBook · Manning

Chapter 10: Graph feature engineering: Manual and semiautomated approaches

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

This introduction explains why graph machine learning needs numerical features and compares manual, semiautomated, and learned ways to create them.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains why graph machine learning needs numerical features and compares manual, semiautomated, and learned ways to create them.

Key terms: vectorization, featurization, graph-based features, feature engineering, semiautomated features, representation learning, interpretability, manually extracted features, interpretable features, autonomous reasoning about graphs

10.1 Manual node features

The section frames fraud detection as supervised node classification and explains why each person in the network needs a feature representation drawn from local or global graph structure.

Key terms: nodes, undirected edges, supervised algorithms, features, label, node features, featurization, metrics, numerical feature vectors, local features

10.1.1 Degree

This section defines node degree and shows how separating fraudulent from legitimate neighbors makes degree more useful for describing a fraud network.

Key terms: degree, global degree, fraud degree, legit degree, direct neighbors

10.1.2 Triangles

Defines graph triangles and explains what they indicate about a node’s neighborhood, including how the example classifies triangles by the fraud status of two alters.

Key terms: triangle, subgraph, egonet, alters, fraudulent, legitimate, semifraudulent

10.1.3 Density

This section defines graph density as the share of possible edges that exist and shows how to calculate it for a node’s egonet.

Key terms: density, possible edges, observed edges, egonet, egonet density, fraud density, legit density

10.1.4 Geodesic (or shortest) path

This subsection turns shortest-path distances and nearby-fraudster path counts into features for a fraud detection network, then explains why they are computed automatically.

Key terms: geodesic path, shortest path, geodesic distance, hops, fraudulent nodes, Dijkstra’s algorithm, networkx, single source, predefined distance

10.1.5 Closeness

This section explains how closeness centrality uses shortest-path distances to measure a node’s position in a network, including when some nodes are unreachable.

Key terms: closeness centrality, farness, geodesic, shortest path, reachable nodes, disconnected components

10.1.6 Betweenness

This section explains betweenness centrality as a measure of how often a node bridges shortest paths and shows how its scores can identify important nodes in a fraud network.

Key terms: betweenness centrality, closeness centrality, shortest paths, σst, σst(v), betweenness values, normalized, bottlenecks, fraud detection

10.1.7 PageRank

This section explains how PageRank measures node importance and how comparing ordinary and fraud-weighted scores can flag nodes for investigation.

Key terms: PageRank, incoming connections, node importance, base PageRank, fraud-weighted PageRank, known fraudulent nodes

10.1.8 Prediction

This subsection uses manually extracted node features to train a fraud classifier and explains how to prepare, interpret, and judge the resulting predictions.

Key terms: node features, logistic regression, feature vector, training, validation, stratified split, StandardScaler, feature importance, fraudulent nodes, legitimate nodes

10.2 Manual relationship features

The section frames link prediction as a node-pair classification task and introduces two ways to represent potential relationships as features.

Key terms: relationship prediction, link prediction, node pair, binary classification, multiclass classification, node-based combination, feature vectors, node embeddings, path-based features, two-hop paths

10.2.1 Node-based representation

This section explains how to turn two node feature vectors into a representation of a possible link and how to choose a combination method.

Key terms: node-based representation, feature representations, link prediction, Catenate, Average, element-wise average, L1, Manhattan distance, L2, Euclidean distance

10.2.2 Path-based features

This section shows how to represent compound–disease pairs with metapath-based features, make path counts less sensitive to highly connected nodes, and limit the work needed to extract useful features.

Key terms: metapath, compound–disease pair, relationship features, Hetionet, path count, degree-weighted path count, DWPC, intermediate nodes, damping factor, metapath reduction

10.3 Semiautomated feature extraction

This section explains how ReFeX extracts interpretable structural graph features with less manual work, while retaining a role for domain experts.

Key terms: ReFeX, Recursive Feature eXtraction, interpretability, human oversight, structural, regional features, feature matrix F, transferable across graphs, local feature extraction, degree

10.3.1 Performing ReFeX manually

The section works through ReFeX on a small undirected graph, from degree and egonet features to recursive aggregation of neighboring features.

Key terms: degree, egonet, internal edges, in/out egonet edges, recursive feature aggregation, SUM operator, MEAN operator, iteration

10.3.2 Performing ReFeX automatically with code

This section positions ReFeX between manual feature engineering and autonomous representation learning, explaining its practical strengths and limitations.

Key terms: ReFeX, automated feature extraction, graph structure, structural patterns, interpretability, deterministic, selective recomputation, node attributes, edge types, pruning

10.4 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 9: Machine learning on knowledge graphs: A primer approach Chapter 11: Graph representation learning and graph neural networks →

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.