Tag similarity
"Which games are like this one?" is answered from tags alone. The same numbers drive the Similar Games page, compare, the similarity map and heatmap, the MCP tools, and the tagged-alike signal of the recommender.
The model: IDF-weighted cosine similarity
Every tagged game becomes a sparse vector over all characteristics (TagVectors). For game g and characteristic c:
idf(c) = ln((N + 1) / (df(c) + 1)) x RarityStrength + 1
N = number of tagged games
df(c) = number of games tagged with c
origin(t) = ManualWeight if Manual
= SourceWeight if Source
= InferredWeight x clamp(confidence, MinConfidence, 1) if Inferred (when UseConfidence)
w(g, c) = idf(c) x origin(tag) x categoryWeight(c)
v(g) = w(g, .) / ||w(g, .)|| length-normalised
similarity(a, b) = v(a) . v(b) cosine, 0 to 1
- Rare tags count more. Sharing "Ancient Egypt" says more than sharing "Slots".
RarityStrength(0 to 3) tunes how much more; 0 makes every tag equal. - AI tags count less until reviewed, in proportion to their confidence.
- Category weights (0 to 3) let a product manager say "theme matters twice as much as features". A characteristic takes the weight of its nearest ancestor category that has one.
- Normalisation means a game with many tags is not automatically "similar to everything".
Worked example
Three tagged games, 100 tagged games in total:
| Tag | Games with it (df) | idf (strength 1) |
|---|---|---|
| Slots | 95 | ln(101/96) + 1 = 1.05 |
| Egypt | 4 | ln(101/5) + 1 = 4.01 |
| Free spins | 60 | ln(101/61) + 1 = 1.50 |
Game A {Slots, Egypt, Free spins} and Game B {Slots, Egypt} share Egypt, which carries most of the score. Game C {Slots, Free spins} shares two tags with A but scores lower, because they are common.
Settings (/similarity/settings)
| Setting | Default | Range |
|---|---|---|
RarityStrength | 1 | 0 to 3 |
ManualWeight, SourceWeight, InferredWeight | 1 | 0 to 2 (sum above 0) |
UseConfidence | true | |
MinConfidence | 0.05 | 0 to 1 |
MinScore | 0 | 0 to 0.95: neighbours below are dropped |
DefaultLimit, MaxLimit | 12, 50 | MaxLimit 1 to 200 |
CategoryWeights | none | per category, 0 to 3 |
Every save bumps Revision. POST /similarity/settings/preview builds vectors with unsaved settings and returns the current and proposed lists for one game side by side (not cached).
Caching and persistence
Building vectors reads every tag, so SimilarityService caches them and rebuilds only when something relevant changed.
The persisted copy is only a cache: a restart or a second API instance loads vectors instead of rebuilding them, and a stale or corrupt snapshot is simply rebuilt. Scoring always happens in memory.
Queries
| Query | Implementation |
|---|---|
Similar(game, k, allow?) | Dense copy of the game's vector, dot product with every other game's sparse vector, keep scores above 1e-6 and MinScore, top k with shared tags ordered by contribution. ?sameType=true restricts to the same game type. |
Compare(a, b) | Score, each shared tag's share of the score (shares add up to 1) and rarity (share of games with it), plus tags only A or only B has. |
Map() | Two principal components by power iteration (80 iterations, orthogonalised), computed on the sparse vectors without building a dense matrix. Axis labels are the 4 strongest positive and negative characteristic loadings. A small, repeatable jitter keeps identical games visible. |
Layout(method) | pca (default), umap (neighbours 3 to 50, min distance 0 to 1, seeded from PCA) or graph (force layout over the strongest links). Reports a trustworthiness score of the 2D layout. |
Heatmap() | Games and tags in clustered order, with cell weights |
/similarity/export | Pages of games with ExternalRef, each with its top-k neighbours named by GameRef, for the recommender's catalogue build and the simulator's game pool |
From similarity to recommendations
The recommender copies the top 30 neighbours per game during a catalogue build (Kind = 0 rows in recommender.neighbour). A tag edit therefore reaches recommendations at the next catalogue build, which can be scheduled with Builds:CatalogueEveryMinutes.