liveBook · Manning

Link prediction

As explained in Graph Algorithms for Data Science

Link prediction is a graph machine learning task that predicts prospective relationships between nodes, optionally including their relationship types.

Link prediction estimates whether a relationship between two nodes is likely to appear, or whether a missing relationship should exist. It is useful when networks change over time, such as friendships, and when incomplete networks hide plausible connections, such as drug–disease relationships. In a user–product graph, predicted links can become personalized recommendations. section 10.0 section 10.6

Treat each candidate connection as a pair of nodes, not as an isolated node. Build pair features from combined node properties or embeddings, shortest-path distance, and neighborhood overlap. Common-neighbor counts and Jaccard similarity capture shared local context; degree products capture preferential attachment. section 10.1 section 10.6

Figure 10.4 Link prediction flow
10-04

Use the workflow diagram to distinguish the feature graph from the labeled relationship samples used to train and test a classifier. section 10.1

Build a link prediction workflow in separate stages:

  • Split relationships into a feature set and train/test samples. When timestamps exist, derive features from earlier links and label later links; keep feature relationships out of training and testing to avoid leakage. section 10.2.1 section 10.6
  • Create positive samples from observed links and negative samples from pairs without the target relationship. Subsample negatives to avoid severe class imbalance. section 10.4 section 10.6
  • Train a binary classifier on the pair features and evaluate it on held-out samples. A random forest is one option; logistic regression and support vector machines are alternatives. section 10.4

Predicting new friendships

If Luke and Rajiv share friends and are close in the network, their pair can receive a higher predicted probability than Jose and Alice. The prediction uses network structure rather than personal characteristics alone, because shared social context helps indicate whether people may meet. section 10.0 section 10.1

Inspect feature distributions before modeling. A feature with little variation, such as a distance that is almost always two hops, may be less useful than a feature with a wider range. Also account for embedding limits: transductive node embeddings cannot represent unseen nodes, so they cannot predict links for nodes absent during training. section 10.4 section 10.6

How Graph Algorithms for Data Science covers it

How deep it goes
Walks through pair-feature construction, leakage-safe splitting, negative sampling, and binary-classifier training without optimization details.
Examples
Uses friendship pairs, user–product purchases, drug–disease links, and Twitch shared audiences.
What it assumes
Introduces graph pair features from concrete networks without assuming graph-theory expertise.
What you can do after
Apply it via Cypher, pandas, and a classifier to train and evaluate relationship predictions from graph features.
How it connects
Connects node embeddings, shortest paths, Jaccard similarity, preferential attachment, Adamic-Adar, and binary classification.

Also explained in

Compare how 3 books explain link prediction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.