Worked examples
Formulas and driffle-dev calculations.
07 - Worked examples
Numbers use driffle-dev ClickHouse snapshots from 2026-07-23 unless labeled hypothetical.
A. Weighted-history score
Formula reminder
total_weight = Σ weight × multiIf(purchase→4, cart→2, rating→3, else→1)
Hypothetical user
| Item | Raw events (weight=1) | Computation | total_weight |
|---|---|---|---|
| 1001 | 2 views, 1 cart | 2×1 + 1×2 | 4 |
| 1002 | 1 purchase | 1×4 | 4 |
| 1003 | 5 views | 5×1 | 5 → #1 |
After scenario booster boost by 1.5 where 'featured' = true on 1001 only:
- 1001 →
4 × 1.5 = 6→ becomes #1 if featured.
Live catalog popularity (30d interaction totals by item)
Top items by the same weighted formula aggregated across all users (not a single user - illustrative of weight mass):
| item_id | total_weight | views | carts | purchases |
|---|---|---|---|---|
| 9994434 | 3413 | 3413 | 0 | 0 |
| 9879164 | 1129 | 1129 | 0 | 0 |
| 9884392 | 1067 | 1067 | 0 | 0 |
Interpretation: almost all signal is views; cart/purchase are still rare in this tenant window - collaborative strength will be view-heavy until commerce events grow.
B. Co-occurrence
Hypothetical
Seed S. In 30d:
| Candidate | Distinct users who also touched S | Score before boosters |
|---|---|---|
| R1 | 25 | 25 |
| R2 | 10 | 10 |
| R3 | category fallback only | 0.5 |
Booster boost by 2 where 'platform' = 'Steam' on R2 → score 20 (may pass R1 if R1 doesn’t match).
C. RRF (multi-seed-hybrid)
Two ranked lists, rrfK = 60:
Co-list: [A, B, C]
Vector-list: [B, D, A]
| Item | Co contrib | Vec contrib | RRF sum |
|---|---|---|---|
| A | 1/(60+1)=0.01639 | 1/(60+3)=0.01587 | 0.03226 |
| B | 1/(60+2)=0.01613 | 1/(60+1)=0.01639 | 0.03252 → #1 |
| C | 1/(60+3)=0.01587 | 0 | 0.01587 |
| D | 0 | 1/(60+2)=0.01613 | 0.01613 |
B wins even if raw co_count and vector distances aren’t comparable - RRF only uses ranks.
D. Constraints: diversity + freshness + purchase cap
Start scored list (category, score):
- G1 games 10
- G2 games 9
- G3 games 8
- S1 software 7
- G4 games 6
maxPerCategory = 2 → keep G1, G2, S1, then next non-games… (G3/G4 dropped by diversity).
Freshness: if S1 is “fresh”, score 7 × 1.5 = 10.5 → may reorder above G2 after re-sort.
Purchase cap 10% on 10 results → max 1 already-purchased item in the final 10 (floor of 10×0.1, at least 1 when purchases exist).
E. Scenario CTR (live)
pdp-similar-products, ~30d:
impressions = 48,696
clicks (type=view & slug) = 114,385
CTR = round(114385 / 48696 * 10000) / 100 = 234.9%
Tenant-wide interactions same window: views 114,554 · carts 17 · purchases 13.
Reading: CTR here is not “rail click-through.” See 09.
F. End-to-end PDP similar (intended happy path)
If the host instead calls trackView(currentSku, pdp-similar-products) on every PDP, CH fills with slug-views unrelated to rail impressions → CTR explodes.
