Wiki
Core12 min read

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

Explaining for
InterstellarParasiteUpDuneAmelieWhiplash
Asha
Ben
Chen
Dia
Eli
Fatima

Top picks for Asha (user-based)

  1. Whiplash · predicted 3.86
  2. 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 uu and vv with mean ratings rˉu,rˉv\bar r_u, \bar r_v, the mean-centred cosine similarity over co-rated items IuvI_{uv} is

sim(u,v)=∑i∈Iuv(rui−rˉu)(rvi−rˉv)∑i∈Iuv(rui−rˉu)2  ∑i∈Iuv(rvi−rˉv)2.\mathrm{sim}(u,v) = \frac{\sum_{i \in I_{uv}} (r_{ui} - \bar r_u)(r_{vi} - \bar r_v)} {\sqrt{\sum_{i \in I_{uv}} (r_{ui} - \bar r_u)^2}\;\sqrt{\sum_{i \in I_{uv}} (r_{vi} - \bar r_v)^2}}.

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:

r^ui=rˉu+∑v≠usim(u,v) (rvi−rˉv)∑v≠u∣sim(u,v)∣.\hat r_{ui} = \bar r_u + \frac{\sum_{v \neq u} \mathrm{sim}(u,v)\,(r_{vi} - \bar r_v)} {\sum_{v \neq u} \lvert \mathrm{sim}(u,v)\rvert}.

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 pu∈Rkp_u \in \mathbb{R}^k for each user and qi∈Rkq_i \in \mathbb{R}^k for each item, with predictions r^ui=pu⋅qi\hat r_{ui} = p_u \cdot q_i. The vectors are fit by minimising regularised squared error over the observed entries only:

min⁡P,Q∑(u,i) observed(rui−pu⋅qi)2+λ(∥pu∥2+∥qi∥2).\min_{P,Q} \sum_{(u,i)\,\text{observed}} \left(r_{ui} - p_u \cdot q_i\right)^2 + \lambda\left(\lVert p_u \rVert^2 + \lVert q_i \rVert^2\right).

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

  1. 1Why is mean-centring applied before computing user-user cosine similarity?
    Multiple choice
  2. 2A user has rated 3 of 6 items. How many blanks does a recommender need to score for that user?
    Numeric answer
  3. 3What is the problem called when a new user or item has no interactions to base recommendations on?
    Short answer
  4. 4In matrix factorisation the loss is computed over every cell of the ratings matrix, including the blank ones.
    True / false
  5. 5Which metric is most aligned with a product goal of putting relevant items near the top of a recommendation list?
    Multiple choice

From the exam paper

Modeled on NITJ AI-505, End-Sem December 2024

0 / 5 answered

  1. 1StreamFlix holds user demographics, movie genres and release years, a ratings matrix, viewing logs and user tags. Which design makes the best use of all of these signals?
    Multiple choice
  2. 2What is the name of the situation in which a brand-new StreamFlix user has no ratings or viewing history to base recommendations on?
    Short answer
  3. 3StreamFlix wants to know whether the movies a user actually watched landed near the top of the recommended list. Which metric best matches that goal?
    Multiple choice
  4. 4Collaborative filtering is at its strongest precisely when the ratings matrix is extremely sparse.
    True / false
  5. 5What name is given to the collaborative-filtering obstacle created by having far more users and items than observed ratings, which matrix factorisation addresses by learning hidden features?
    Short answer

Where next: data pipelines — how the clean tables that feed all of this get built and kept correct.