Applications of Machine Learning

Lecture 22 · Animations

Recommender systems: neural, and evaluated honestly

One decision about how to score a recommender that moves the number more than the model does: which of a user’s interactions is held out. Press Step to advance one unit and read what happened; press Play to let it run.

All data on this page is synthetic, generated in your browser from a fixed seed, so Reset always gives back the same picture. The widget says how its users and items were generated; none of the numbers is a MovieLens number.

1A random split leaks the future

300 users, 200 films. Each user’s history is an ordered sequence of 12 to 30 films; their taste drifts along it, and early choices lean on popularity more than late ones. Each Step evaluates one more user under both protocols: hold out one interaction at random, or hold out the last. On the left, the timelines of the users just evaluated: the held-out film is the diamond, and every red mark is an interaction from after it that the model was trained on. On the right, HR@10 so far for a popularity list and an item–item model, under both splits.

The mathematics

For a user with history $i_1, \dots, i_T$ in time order, the random split holds out $i_t$ with $t$ uniform on $\{1,\dots,T\}$ and trains on the other $T-1$; of those, $T - t$ come after the held-out one, so on average $(T-1)/2$ — half the training history — is the user’s future. The temporal split holds out $i_T$, and none is. The item–item model scores a candidate $j$ by $\sum_{i \in H_u} s_{ij}$ over the user’s training history $H_u$, with $s_{ij} = c_{ij}/\sqrt{c_i\,c_j}$, where $c_{ij}$ counts users with both $i$ and $j$ in training and $c_i$ users with $i$. Seen films are removed from the candidates before ranking.

Watch for
  • Under the random split, red marks sit on both sides of the diamond: the model has seen what the user did next, and with a drifting taste that is the most informative evidence there is.
  • The random split lifts both models, the popularity list included, by a similar factor. A gain that lifts the unpersonalised baseline as much as the model is the task getting easier, not the model getting better.
Try this
  1. Play to the end and read the two ratios in the side panel: the random split more than doubles both models’ HR@10.
  2. Read future in training, the share of the random split’s training interactions that come after the held-out one: about half, as the expectation $(T-1)/2$ predicts.