Course / Lectures / Lecture 09 / Lab Lab 09

Link prediction, two ways.

A typed graph with six held-out facts. Choose a relation, train a tiny TransE or RotatE model by negative sampling, and compare its top-k predictions with a rule miner. Every number is computed in your browser.

23 entities 6 relations 49 triples 6 held out No install · runs from file://

The link-prediction lab

Query

spouse(niko, ?)

Held-out answer

mira

#CandidateEmbeddingRuleNote

Heads marked † have a held-out fact. Filtered ranking removes other known tails for the same head from the candidate list.

PCA projection of the entity embeddings. Teal: people. Orange: cities. Blue: countries. Grey: organisations.
Relation vector for the selected relation.

Loading the toy graph…

Query

Evaluation

Six held-out facts, one per relation. Filtered ranking; ties count as average rank. Live numbers from this run, not a benchmark.

ScorerHits@1Hits@3MRR

Mined rules

Bodies of one or two atoms, confidence ≥ 0.5, mined on the training split. Support · confidence · head coverage.

Embedding scores are min–max normalized over the candidate set. Rule scores are the maximum confidence of a firing rule, or 0 if none fires.

WHAT TO NOTICE

Two inductive biases, one graph.

REGIME 01 · GEOMETRY

The algebra decides

TransE translates, RotatE rotates. The symmetric spouse relation is the clean test: a rule can invert it exactly, while TransE cannot represent a non-trivial symmetric relation without collapsing the two entities.

REGIME 02 · RULES

Precision is not coverage

A rule with confidence 1.0 and support 2 is anecdotal. The table reports support, confidence, and head coverage together, because no single number ranks rules.

REGIME 03 · EVALUATION

Six facts is not a benchmark

Every metric on this page is computed on six held-out edges of a hand-built graph. It shows the mechanism — filtered ranking, negative sampling, rule scoring — not the state of the art.

What this lab is — and is not

It is a real TransE/RotatE trainer and a real rule miner, both small enough to read. It is not a knowledge-graph benchmark: the graph is fictional, the test set has six facts, the rule miner searches only one- and two-atom bodies, and the 2D projection is a lossy view of a 12-dimensional space. A result here is a mechanism, not a claim about a real graph.

← Read the embedding section · The rule metrics · Slides →