How it works
Collaborative filtering rests on one insight: people whose past behaviour is similar tend to have
similar tastes. If users A and B bought the same ten products, then the products A bought and B did
not are a good recommendation for B.
Mathematically this is expressed through the interaction matrix:
Item 1 Item 2 Item 3 Item 4
User A 1 1 0 1
User B 1 1 0 ?
User C 0 1 1 1
CF predicts that B will probably buy Item 4 — as A did, and B resembles A.
Two CF architectures
Memory-based CF finds similar users or items directly, through cosine similarity or Pearson
correlation. It works for small catalogues and does not scale to millions of users.
Model-based CF trains a model (matrix factorization, neural networks) that compresses the
interaction matrix into compact vectors, or latent factors. It scales to large catalogues and is
faster at inference time.
| Parameter | Memory-based | Model-based |
|---|---|---|
| Scalability | Limited | High |
| Cold start | Not addressed | Partly addressed |
| Training speed | No training | Needs regular retraining |
| Explainability | High (people like you) | Low (latent factors) |
Item-based CF in practice
In e-commerce, item-based CF is preferable to user-based for several reasons:
- There are orders of magnitude fewer products than users, so the matrix is more manageable
- Item similarity is more stable over time: coffee machine plus capsules is a durable pair
- It does not require finding similar users in real time — the results are pre-computed
Tip: for a Frequently bought together block, use item-based CF over co-purchase patterns. For a
You might like block, use user-based or model-based CF across the full browsing history.
Limitations
- Cold start — no history means no recommendations. Fix: content-based filtering as a fallback.
- Matrix sparsity — in large catalogues most cells are empty. Fix: matrix factorization.
- Popularity bias — the algorithm gravitates toward popular products and ignores the long tail.
Fix: diversification and explorative strategies. - Filter bubble — the shopper only ever sees what resembles their past. Fix: add a novelty component.