Affinity: how much a customer likes a game
Affinity is a number from 0 to 1 per customer and game. It is the starting point of every personalised recommendation. Two implementations compute it from the same idea; they differ in how they handle time.
Batch (Kaleido.Gre.Profile/Affinity.cs) | Live (Kaleido.Gre.Stream/StreamAffinity.cs) | |
|---|---|---|
| Input | Totals per game over a window (default 60 days) from the activity service | Decayed running totals per game from Redis |
| Recency | A separate factor from the last-played date | Built into the totals: every event fades with the half-life |
| When | On a profile build | On every recommendation request |
The three signals
For each game the customer played, three engagement signals are taken. Payouts are not a signal: winnings say nothing about how much someone enjoys a game.
| Signal | Raw value | Squashed |
|---|---|---|
| Count | number of wagers | ln(1 + bets) |
| Amount | money staked | ln(1 + stake) |
| Time | minutes played | ln(1 + seconds / 60) |
The logarithm gives diminishing returns, so one huge stake or a marathon session cannot drown everything else.
Per-customer normalisation
Each squashed signal is divided by the customer's own maximum for that signal. A high roller and a casual player are judged on their own scale; their favourite game scores 1 on each signal.
c = ln(1 + bets_g) / max over games ln(1 + bets)
a = ln(1 + stake_g) / max over games ln(1 + stake)
t = ln(1 + minutes_g) / max over games ln(1 + minutes)
blended = (CountWeight x c + AmountWeight x a + TimeWeight x t) / (CountWeight + AmountWeight + TimeWeight)
Recency
Batch. The blended score is multiplied by 0.5 ^ (days since last played / HalfLifeDays). With the default 14 days, a game last played 14 days ago keeps half its score, 28 days a quarter. HalfLifeDays = 0 turns decay off.
Live. The totals themselves fade (see the decayed counter), and they are decayed to "now" when read, so there is no separate factor. This is also more accurate: a game played heavily 25 days ago and once yesterday is no longer treated as "played yesterday" in full.
Cut-off
Scores below MinScore (default 0.05) are dropped as noise. Results are ordered by score, then by game ref for stable output.
Worked example
Sam over the last 60 days, half-life 14 days, equal weights:
| Game | Bets | Stake | Minutes | Last played | c | a | t | Blended | Recency | Affinity |
|---|---|---|---|---|---|---|---|---|---|---|
| Dragon Gold | 200 | 400 | 120 | 1 day | 1.00 | 1.00 | 1.00 | 1.00 | 0.95 | 0.95 |
| Pirate Cove | 60 | 60 | 30 | 10 days | 0.78 | 0.69 | 0.72 | 0.73 | 0.61 | 0.44 |
| Lucky Fruits | 5 | 5 | 3 | 40 days | 0.34 | 0.30 | 0.29 | 0.31 | 0.14 | 0.04, dropped |
Sequence: batch versus live
Tuning
Batch settings are in the profile service (/settings, Tune panel). Live weights are configuration on the recommender (Stream:CountWeight, Stream:AmountWeight, Stream:TimeWeight, Stream:MinScore) and the half-life is Stream:HalfLifeDays on both ingest and recommender, which must match.