1 · What is a recommender system?
Every 'recommended for you' feed solves one problem: given who you are and what everyone has done, predict what you'll want next. Meet the rating matrix at its heart.
A recommender predicts how much each user will like each item, then ranks the unseen items. Almost all of it reduces to filling in the blanks of a sparse user × item rating matrix and sorting the predictions.
Without this:
Without recommenders, users drown in catalogs of millions and see only what they search for. Recommenders are how Netflix, Spotify, YouTube, and Amazon surface the right item from an impossible haystack.
Search answers 'find me this'. A recommender system answers a harder question — 'show me something I'll like that I didn't know to ask for'. It's the engine behind Netflix's home rows, Spotify's Discover Weekly, YouTube's up-next, Amazon's 'customers also bought', and your social feed.
At its core sits one object: the user × item interaction matrix R, where R[u,i] is how user u feels about item i — a 1–5 star rating, a watch count, a click, a purchase. The catch is that R is mostly empty: any single user has interacted with a tiny fraction of the catalog. The whole job of a recommender is to predict the missing entries and then rank the highest-predicted unseen items for each user.
Three broad families do this, and you'll build all of them:
- Content-based (Chapter 2): recommend items similar in features to what you already liked.
- Collaborative filtering (Chapters 3–4): recommend what similar users liked, learning purely from the matrix.
- Hybrid (Chapter 6): combine both, plus context.
Below is the simplest recommender — a popularity baseline — on a tiny rating matrix. It ignores personalization and recommends what's globally most-loved. Weak, but it's the bar every real model must beat, and it never suffers cold-start.
Python (in browser)
The user × item rating matrix + a popularity baseline. It works but isn't personalized — the bar everything else must beat.
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
What is the central data structure a recommender system works with?
- A recommender predicts the missing entries of a sparse user × item matrix, then ranks the top unseen items per user.
- Three families: content-based (item features), collaborative filtering (the matrix alone), and hybrid.
- A popularity baseline (recommend the globally most-loved) is the weak but cold-start-proof bar every model must beat.
Netflix, Spotify, YouTube, Amazon, TikTok, and every e-commerce 'you may also like' module are recommender systems.
If you remove it: Without recommenders, discovery collapses to search alone — users never find the long tail, and engagement craters.