Skip to main content

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)
InputTotals per game over a window (default 60 days) from the activity serviceDecayed running totals per game from Redis
RecencyA separate factor from the last-played dateBuilt into the totals: every event fades with the half-life
WhenOn a profile buildOn 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.

SignalRaw valueSquashed
Countnumber of wagersln(1 + bets)
Amountmoney stakedln(1 + stake)
Timeminutes playedln(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:

GameBetsStakeMinutesLast playedcatBlendedRecencyAffinity
Dragon Gold2004001201 day1.001.001.001.000.950.95
Pirate Cove60603010 days0.780.690.720.730.610.44
Lucky Fruits55340 days0.340.300.290.310.140.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.