Notes

Contextual Pre-Filtering

If you want recommendations that suit a Saturday night, one obvious move is to look only at what people did on Saturday nights. Contextual pre-filtering is that instinct turned into a method: narrow the data to the current situation first, then recommend exactly as usual.

Narrow the data, reuse the model
The context of the request becomes a query over the interaction log. Only the interactions whose context matches are kept, and that slice is handed to an ordinary two-dimensional recommender. The model never sees a context variable at all — the data selection has already encoded it. Matching is rarely exact: the slice is generalised to a coarser bucket, weekend rather than Saturday, evening rather than 21:17, through a hierarchy of contexts. Either a model is trained per segment offline, or the slice is selected at query time and scored on the spot.

The trade-off it forces

  • Sparsity multiplies. A matrix already ninety-nine per cent empty, split across contexts, leaves segments with too few interactions to learn anything from — the dominant failure mode.
  • Cold start reappears inside each slice: a user who is active overall can be brand new within one context.
  • Operationally, many contexts mean many models to train, store and serve.
  • In exchange the existing stack is untouched. An off-the-shelf implementation, implicit ALS included, runs on the slice unmodified.

When to reach for it
It suits contexts that genuinely partition behaviour and are each large enough to support a model — a delivery app's lunch and dinner traffic. Where contexts are many or fine-grained, contextual modelling shares strength across them instead of splitting the data, and usually wins.

Contextual pre-filtering restricts the interaction data to records matching the current context — weekend, mobile, evening — and then runs a conventional user-item recommender on that slice, so no context variable ever enters the model. It reuses an existing stack unchanged, and generalising the context to coarser buckets is what keeps it workable. Its cost is sparsity: every split leaves fewer interactions per segment to learn from.

Suppose you want to know what to suggest on a Sunday morning. The simplest approach is to throw away every record except the Sunday mornings, and work only from what is left.

That is contextual pre-filtering. The software picks out the part of its history that matches the current moment, then makes its usual guess from that alone. It is easy to do and needs no new machinery, which is why it is often the first thing anyone tries. The catch is simple arithmetic. Slice a small pile of evidence into many smaller piles and some of them end up nearly empty — and a guess made from three examples is not much of a guess at all.