Recommendation systems
From a sparse ratings matrix: neighbourhood similarity, matrix factorisation, and the cold-start problem no algorithm escapes.
Netflix's catalogue and your viewing history are both enormous, and the intersection is tiny. Most users have rated or watched a vanishing fraction of the items, so the data is a matrix that is almost entirely blank. A recommender's job is to fill in the blanks well enough to order them — and to do so while a user's tastes and an item's popularity are both moving.
The matrix below is small enough to read. Click a blank to accept the model's prediction, clear a rating to remove evidence, and switch between user-based and item-based reasoning. Every cell is recomputed from the ratings in front of you.
Click a blank to fill it with the model prediction, a filled cell to erase it
| Interstellar | Parasite | Up | Dune | Amelie | Whiplash | |
|---|---|---|---|---|---|---|
| Asha | ||||||
| Ben | ||||||
| Chen | ||||||
| Dia | ||||||
| Eli | ||||||
| Fatima |
Top picks for Asha (user-based)
- Whiplash · predicted 3.86
- Dune · predicted 3.21
Six users and six films is a toy, and cosine on co-rated items is the simplest neighbour model — production systems use matrix factorisation or learned embeddings at a scale this grid cannot show. But the failure modes are visible even here: erasing a rating changes the predictions, so a recommender is only as stable as its input data.
Two ways to say 'similar'
User-based collaborative filtering says: find people whose ratings look like yours, and recommend what they liked. Item-based says: find items that tend to be rated like the items you liked, and recommend those. The two use the same cosine formula on different axes of the same matrix, and which one wins depends on whether you have more users than items.
Similarity and the neighbourhood model
For users and with mean ratings , the mean-centred cosine similarity over co-rated items is
Subtracting each user's mean removes the "easy grader" effect. A prediction for a blank cell is then a similarity-weighted average of neighbours' deviations:
Only positive similarities contribute, so dissimilar users do not drag the prediction the wrong way.
Matrix factorisation
Neighbourhood models need overlap to measure similarity, which is exactly what sparse data lacks. Latent-factor models instead learn a low-rank structure: a vector for each user and for each item, with predictions . The vectors are fit by minimising regularised squared error over the observed entries only:
The regularisation is essential — with so few observed entries, an unregularised factorisation simply memorises them. The learned dimensions are not interpretable labels like "likes science fiction"; they are whatever directions best explain co-occurrence.
Ranking, not rating, and the cold start
A recommender is usually judged not on rating accuracy but on ranking: is the item the user actually engaged with near the top of the list? RMSE and ranking metrics (precision@k, NDCG, recall@k) can disagree sharply, and the metric that matters is the one tied to the product decision. Two problems no amount of modelling removes:
- Cold start. A brand-new user or item has no interactions, so neither similarity nor latent factors exist for it. The usual fixes are content features, popularity priors, and deliberate exploration.
- Feedback loops. Recommending an item generates the interactions that justify recommending it again, which narrows the catalogue and can amplify bias. Deployed systems deliberately inject exploration to counter this.
Careful
Offline accuracy is a weak proxy for online value. A model can improve RMSE while reducing the diversity, novelty, or long-term engagement the product actually wants; recommendations can also encode and amplify historical bias in the data. Evaluate what the business cares about, watch the distribution of what you surface, and keep a human-meaningful account of why an item appeared.
Illustrative vs real
Six users and six films is a toy, and the artifact uses simple mean-centred cosine neighbourhoods — not matrix factorisation, not learned embeddings, not implicit feedback. Real systems work at a scale where approximate nearest-neighbour search is mandatory. But the failure modes visible here — a prediction changing when one rating is removed, an item nobody has rated being unrecommendable — are the same ones that matter at scale.
Check yourself
Eduspheria wiki · Data, MLOps & Deployment, Features & recommenders
0 / 5 answered
From the exam paper
Modeled on NITJ AI-505, End-Sem December 2024
0 / 5 answered
Where next: data pipelines — how the clean tables that feed all of this get built and kept correct.