| profile coordinates | candidate evidence | ||
|---|---|---|---|
| user | M1 | M2 | M3 |
| Anna | 0.4 | 0.2 | 0 |
| Pavel | 0.8 | 0.4 | 1 |
| Jan | 0 | 0.8 | 0.7 |
| Mario | 0.4 | 0.4 | 0 |
| Luigi | 0.2 | 0.3 | 0 |
| rank | class | distance |
| 1 | 1.6 | |
| 2 | 2.0 | |
| 3 | 2.4 | |
| 4 | 3.1 |
Recorded behaviour is not a class label: instead of voting, we average the evidence.
| neighbour | watched M3? | adds |
|---|---|---|
| neighbour 1 | 1 | 1 |
| neighbour 2 | 0 | 0 |
Every k-NN recommender is defined by three choices.
What coordinates describe a user or an item?
Two sources of similarity: what people do and what items are.
What is the best way to represent these items for finding neighbours?
| item | black | red | chair | T-shirt | price (CZK) |
|---|---|---|---|---|---|
| Office chair | 1 | 0 | 1 | 0 | 1 105 |
| Egg chair | 1 | 0 | 1 | 0 | 24 937 |
| Egg chair | 0 | 1 | 1 | 0 | 24 945 |
| Football shirt | 0 | 1 | 0 | 1 | 1 299 |
| item | black | red | chair | T-shirt | price (CZK) | price scaled |
|---|---|---|---|---|---|---|
| Office chair | 1 | 0 | 1 | 0 | 1 105 | 0.00 |
| Egg chair | 1 | 0 | 1 | 0 | 24 937 | 1.00 |
| Egg chair | 0 | 1 | 1 | 0 | 24 945 | 1.00 |
| Football shirt | 0 | 1 | 0 | 1 | 1 299 | 0.01 |
Euclidean distance from the office chair:
| Football shirt | 194 |
| Egg chair (black) | 23 832 |
| Egg chair (red) | 23 840 |
| Egg chair (black) | 1.00 |
| Egg chair (red) | 1.73 |
| Football shirt | 2.00 |
Attribute-based user neighbours: describe each user by $\mathbf{a}_i = (\text{nationality}, \text{age})$.
| user | nationality | age (scaled) |
|---|---|---|
| Anna | 1 | 0.31 |
| Pavel | 1 | 0.27 |
| Jan | 1 | 0.18 |
| Mario | 0 | 0.89 |
| Luigi | 0 | 0.91 |
| user | distance | watched M3 |
|---|---|---|
| Pavel | 0.04 | 1 |
| Jan | 0.13 | 1 |
| Mario | 1.16 | |
| Luigi | 1.17 |
Describe the same users by what they watched, columns 1 and 2 of $X$: $\mathbf{h}_i = (X_{i1}, X_{i2})$.
| user | M1 | M2 |
|---|---|---|
| Anna | 0.4 | 0.2 |
| Pavel | 0.8 | 0.4 |
| Jan | 0 | 0.8 |
| Mario | 0.4 | 0.4 |
| Luigi | 0.2 | 0.3 |
| user | distance | watched M3 |
|---|---|---|
| Mario | 0.200 | 0 |
| Luigi | 0.224 | 0 |
| Pavel | 0.447 | |
| Jan | 0.721 |
Every k-NN recommender is defined by three choices.
Which differences in behaviour should make two users less similar?
| $\Omega^1$ | 1 3 4 8 12 15 17 24 35 39 41 43 | $|\Omega^1| = 12$ |
| $\Omega^2$ | 2 3 4 5 9 12 13 16 19 24 27 31 | $|\Omega^2| = 12$ |
| $\Omega^3$ | 4 5 9 12 | $|\Omega^3| = 4$ |
| $\Omega^4$ | 4 9 | $|\Omega^4| = 2$ |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| user | items $|\Omega^i|$ |
|---|---|
| user 1 | 12 |
| user 2 | 12 |
| user 3 | 4 |
| user 4 | 2 |
| pair | $\cap$ | $\cup$ | Jaccard |
|---|---|---|---|
| $(1,2)$ | 4 | 20 | 0.20 |
| $(1,3)$ | 2 | 14 | 0.14 |
| $(1,4)$ | 1 | 13 | 0.08 |
| $(2,3)$ | 4 | 12 | 0.33 |
| $(2,4)$ | 2 | 12 | 0.17 |
| $(3,4)$ | 2 | 4 | 0.50 |
| pair | count | Jaccard |
|---|---|---|
| $(1,2)$ | 4 | 0.20 |
| $(2,3)$ | 4 | 0.33 |
| $(3,4)$ | 2 | 0.50 |
Two item-presence axes: each user is a vector from the origin.
Back to Anna's completion profiles: the same coordinates as before.
| user | profile | cosine |
|---|---|---|
| Pavel | (0.8, 0.4) | 1.000 |
| Mario | (0.4, 0.4) | 0.949 |
| Luigi | (0.2, 0.3) | 0.868 |
| Jan | (0, 0.8) | 0.447 |
Same scatter, same scale: now measure straight-line distance from Anna.
| user | $d$ | ES $= 1/(1+d)$ |
|---|---|---|
| Mario | 0.200 | 0.833 |
| Luigi | 0.224 | 0.817 |
| Pavel | 0.447 | 0.691 |
| Jan | 0.721 | 0.581 |
An interaction that everyone has says little about whose taste is close.
| user | M1 | M2 |
|---|---|---|
| Anna | 0.4 | 0.2 |
| Pavel | 0.8 | 0.4 |
| Jan | 0 | 0.8 |
| Mario | 0.4 | 0.4 |
| Luigi | 0.2 | 0.3 |
| pair | cosine | shared interactions |
|---|---|---|
| pair A | 1.00 | 2 |
| pair B | ≈ 0.90 | 100 |
| user | Movie 1 | Movie 2 |
|---|---|---|
| Anna | 0 | +1 |
| Pavel | +1 | −1 |
| Jan | +1 | 0 |
| Mario | −1 | 0 |
| Luigi | +1 | +1 |
| pair | cosine | |
|---|---|---|
| Jan, Mario | −1.00 | opposite |
| Anna, Luigi | 0.71 | shared like |
| Anna, Jan | 0.00 | no overlap |
| data | similarity | what it compares |
|---|---|---|
| Binary histories | Cosine or Jaccard | different normalisations of the overlap |
| Nonnegative weighted histories | Cosine | compares relative patterns |
| Likes and dislikes, $\pm 1$ | Cosine | can be negative: opposite opinions |
| Numeric features where magnitude matters | Euclidean | check feature scales first |
Every k-NN recommender is defined by three choices.
How much should each neighbour contribute?
| neighbour $l$ | $\cos(\text{Anna}, l)$ | $B_{l3}$ | product |
|---|---|---|---|
| Pavel | 1.000 | 1 | 1.000 |
| Mario | 0.949 | 0 | 0 |
Should Movie 3 or Movie 4 come first?
| user | $\cos(\text{Anna}, l)$ |
|---|---|
| Pavel | 1.000 |
| Mario | 0.949 |
| Luigi | 0.868 |
| Jan | 0.447 |
| movie | Pavel | Mario | score | |
|---|---|---|---|---|
| M1 | 1 | 1 | 1.000 | watched |
| M2 | 1 | 1 | 1.000 | watched |
| M3 | 1 | 0 | 0.513 | candidate |
| M4 | 0 | 1 | 0.487 | candidate |
| reference user | M1 | M2 | M3 | M4 |
|---|---|---|---|---|
| Pavel | 0.8 | 0.4 | 1 | 0 |
| Mario | 0.4 | 0.4 | 0 | 1 |
| Anna’s candidates | ||||
| user-based | item-based | |
|---|---|---|
| compared objects | user profiles: rows | item profiles: columns |
| full pairwise | $O(m^2)$ | $O(n^2)$ |
| stability | a user's row changes with every click | an item's audience changes slowly: precompute offline |
| stored neighbourhoods | neighbours per user; they change as users act | neighbours per item: precomputed item relationships |
| online evidence aggregation | average the neighbours' interactions with each candidate | average over the items in the user's current history |
| explanation | “people with similar histories watched this” | “related to what you watched” |
Item-based CF with $n = 100\,000$ items. What do we keep in memory?
| user | M1 | M2 | M3 | M4 | M5 (new) |
|---|---|---|---|---|---|
| Anna | 0.4 | 0.2 | 0 | 0 | 0 |
| Pavel | 0.8 | 0.4 | 1 | 0 | 0 |
| Jan | 0 | 0.8 | 0.7 | 0 | 0 |
| Mario | 0.4 | 0.4 | 0 | 1 | 0 |
| Luigi | 0.2 | 0.3 | 0 | 0.6 | 0 |
| Eva (new) | 0 | 0 | 0 | 0 | 0 |
| movie | ES to M5 | Pavel completion |
|---|---|---|
| M3 | 0.876 | 1 |
| M2 | 0.639 | 0.4 |
| M1 | 0.503 | 0.8 |
| M4 | 0.469 | 0 (not watched) |
Everything so far used implicit feedback. Many systems also collect ratings.
Explicit ratings are also partially observed. How similar are Anna and Pavel?
On their co-rated movies (M1, M2, M3, M7, M8), Anna rates low and Pavel rates high.
| user | M1 | M2 | M3 | M7 | M8 | mean |
|---|---|---|---|---|---|---|
| Anna | 3 | 1 | 2 | 1 | 2 | 1.8 |
| Pavel | 5 | 3 | 4 | 3 | 4 | 3.8 |
| user | M1 | M2 | M3 | M7 | M8 |
|---|---|---|---|---|---|
| Anna | +1.2 | −0.8 | +0.2 | −0.8 | +0.2 |
| Pavel | +1.2 | −0.8 | +0.2 | −0.8 | +0.2 |
| user $l$ | $\mathrm{ES}$ | $X_{l3}$ | $\mu_l$ | $X_{l3} - \mu_l$ |
|---|---|---|---|---|
| Anna | NA | ? | 4.50 | NA |
| Mario | 0.50 | 1 | 3.00 | −2.00 |
| Luigi | 0.41 | 2 | 3.67 | −1.67 |