Foundations & the Data Model
Recommender systems are, at their core, the problem of completing a giant, mostly-empty table. Before any algorithm you must agree on what goes in the cells, what the holes mean, and where the numbers come from — the URM, the ICM, explicit vs implicit feedback, and the sparsity that defines the field.
01 · Motivation
Why recommend at all?
Catalogs grew faster than human attention.
A modern catalog — Netflix, Spotify, Amazon, a research-paper database — contains far more items than any user can browse in a lifetime. The classical interface, search, only helps when the user already knows what they want. Recommender systems fill the harder gap: surfacing relevant items a user does not yet know they want.
Mental model
A recommender is a function that ranks every (user, item) pair. The training data is the table of past interactions; the test is whether the user clicks, watches, or buys what we put on top.
Two empirical regularities make this both possible and hard:
- sparsity — for any single user, the fraction of the catalog they have touched is tiny (often ). Most of the table is empty.
- the long tail — a few items get a huge share of interactions; the vast majority get almost none. Personalization is precisely the act of pulling items from the tail to the right user.
02 · Map of the field
A taxonomy of recommenders
One tree to keep in your head for the entire course.
The course follows a single decision tree — memorise this picture. The first split asks does the model use the identity of the target user? If no → Non-Personalized. If yes → Personalized, with sub-families distinguished by what signal they exploit.
The two top-level inputs to all of these are the matrices we define next: the URM (who interacted with what) and the ICM (what each item is). Content-Based mostly reads the ICM; Collaborative mostly reads the URM; Hybrids mix both; Context-Aware adds a third axis — time, location, device.
How to remember the split
Content-based = “find items similar to ones the user liked, by their features.” Collaborative = “find items liked by users similar to me, by their behaviour.” The first reads the ICM, the second reads the URM.
03 · The first matrix
The User Rating Matrix (URM)
Rows are users, columns are items, cells are interactions.
The URM is the central object of collaborative filtering. Each row is a user, each column is an item, and the value records the interaction between user and item .
0 means unknown, not disliked
The URM stores observed interactions only. A zero is missing data — the user has never been shown the item, or simply never reacted. Treating as a negative rating is the most common modelling mistake in this course.
URM / ICM explorer · the toy catalog
The same 6 users × 8 movies (× 9 attributes) reused across the whole course. Click a cell to edit it; switch to Implicit to watch 1–5 ratings collapse to 0/1, and to ICM to see what each movie is made of. A 0 is unknown, not disliked.
Formal Definition 1.1 — the URM
Let be the set of users and the set of items. The User Rating Matrix is
The notation is the value at row , column . We use this symbol for the rest of the course.
04 · The second matrix
The Item Content Matrix (ICM)
Items described by their attributes — the side door into recommendation.
The ICM is orthogonal to the URM: instead of recording who liked what, it describes what each item is made of. Rows are items; columns are attributes (for movies: actors, genres, directors, decade, tags). A cell is 1 if the item has the attribute, 0 if not; weighted variants (e.g. TF-IDF) replace 1s with real numbers. Toggle the explorer above to ICM — those are exactly the rows you see: Top Gun has a 1 in the Cruise column, and so on.
Two matrices, two worldviews
The URM is what users did. The ICM is what items are. Content-Based Filtering only needs the ICM; pure Collaborative Filtering only needs the URM; hybrids combine both.
Formal Definition 1.2 — the ICM
Let be the set of attributes. The Item Content Matrix is
An item is represented by the row vector . Content-based similarity between items reduces to a cosine (or Jaccard) similarity between these rows — Chapter 4.
05 · Where the numbers come from
Explicit vs. implicit feedback
Two ways to fill the URM — with very different statistics.
The URM can be populated in two fundamentally different ways. explicit feedback means the user actively expresses an opinion: a 1–5 star rating, a thumbs up/down, a written review score. implicit feedback means we infer preference from behaviour: a click, a play, the fraction of a video watched, a purchase, dwell time.
Design choices for explicit scales
- Large scales (1–10) carry more information per rating but require more effort, so users give fewer ratings.
- Small scales (thumbs up/down) need almost no effort, so users give many more ratings — at the cost of resolution.
- Even scales (1–4) force the user to pick a side; odd scales (1–5) include a neutral middle users gravitate toward — a real source of bias.
Examples of implicit signals — viewing time and fraction watched, streaming and skip counts, purchases and returns, clicks, dwell time, scroll depth.
Feedback lens · explicit vs implicit
One user's activity over four days. Apply the explicit lens to keep only star ratings; the implicit lens to keep any behavioural signal. Watch the coverage change — explicit is sparser but signed; implicit is denser but ambiguous (a click is not a like).
The one-class problem
Implicit feedback usually has no negatives — we observe presence but never explicit absence. Algorithms designed for explicit data (e.g. RMSE-trained matrix factorization) often misbehave on implicit data. Chapter 7 (BPR) is exactly the response to this asymmetry.
06 · The shape of real data
Sparsity & the long tail
Why “the matrix is empty” is the defining challenge of the field.
Real URMs are spectacularly sparse. Typical URM density is ; the Netflix Prize URM is ; MovieLens is . Roughly 99.99% of the table is unknown. Every recommendation algorithm is, in some sense, a principled way to guess about that 99.99%.
Sparsity is not uniform: a handful of items dominate and most have very few interactions — the long tail. The recommender’s job is to serve the head and bring the tail to life, but the tail is also where the cold start problem lives (items with too few interactions for collaborative signals to work).
Sparsity & the long tail
Our toy URM is 64.6% dense — already mostly empty. Real catalogs are thousands of times sparser. Drag the sliders to feel how density and skew scale up, and how the cold-start zone grows.
Formal Definition 1.3 — density & sparsity
Given a URM , denote the set of observed interactions . Then
For real catalogs density is . This single number is the reason every algorithm we study is either a way of generalizing across the empty cells, or a way of coping with them being empty.
07 · Self-check
Three questions before you move on
In a URM, a value of 0 in cell r(u,i) means:
The Item Content Matrix (ICM) has:
Roughly, the density of the Netflix Prize URM is closest to:
08 · Recap
One-screen summary
Chapter 01 — load-bearing ideas
- The URM holds interactions (users × items). 0 = unknown, never “disliked”.
- The ICM holds item content (items × attributes). It is the back door for content-based methods.
- Real URMs are dense. Sparsity and the long tail are not bugs of the data — they are the problem statement of the entire course.
- Explicit feedback is signed but scarce; implicit feedback is abundant but positive-only (the one-class problem).
- Notation to keep: for the URM, for the ICM, for a single cell, .
09 · Exam · past papers
Past-paper questions
A curated bank of real Polimi past-paper items for this chapter. Each opens to a model answer of the standard graders look for.
Past paper Exam 2020 · 2 pts — personalized vs non-personalized
Q. Discuss the main differences between personalized and non-personalized recommenders, give an example algorithm for each, and explain why it belongs there.
Model answer. Non-personalized recommenders produce the same ranking for everyone: the score depends only on aggregate item statistics, , not on the target user. Example — Top-Popular: it ranks items by total interactions (column sums of the URM); user never enters the formula. Personalized recommenders tailor the list: the prediction uses user ‘s own history. Example — user-based CF: it recommends items liked by users similar to . The core difference is the dependency on .
Past paper FT-Jan26 · 4+2 pts — implicit vs explicit ratings; multi-stage recommenders
Q (4 pts). Describe the differences between implicit and explicit ratings; give an algorithm designed for each and explain why. Q (2 pts). What is a multi-stage recommender and what is the purpose of each stage?
Model answer. Explicit ratings are stated preferences (1–5 stars): informative and signed (a low rating is a real negative) but scarce and biased toward motivated users. Implicit ratings are inferred from behaviour: abundant but noisy and positive-only — a 0 means “unknown”, so there are no observed negatives, only confidence. Explicit → Funk SVD / MF with RMSE on the observed entries (it predicts the rating value). Implicit → BPR (or ALS with confidence weighting): it optimises a ranking from “positive > unobserved” pairs, precisely because true negatives are missing. Multi-stage recommender — a pipeline that trades scale for accuracy: (1) candidate generation / retrieval (cheap, recall-oriented, scans the whole catalog → a few hundred candidates); (2) ranking (expensive, precision-oriented, re-scores only that small set); (3) re-ranking (optional: diversity, freshness, business rules). You cannot run a heavy model over millions of items per request.
Past paper FT-Feb26 · 2 pts — model-based vs memory-based
Q. Discuss the main differences between model-based and memory-based algorithms; give an example of each and explain why.
Model answer. Memory-based methods keep the raw URM and compute recommendations directly at query time from similarity heuristics — no learned parameters. Example — user/item-based KNN CF. Model-based methods learn a compact parametric model offline by minimising a loss; predictions come from the fitted parameters. Example — Matrix Factorization (or SLIM). Trade-off: memory-based is lazy, interpretable, costly at query time and degrades under sparsity; model-based trains offline, generalises, and is compact and fast at inference.
Past paper Practice Exam · popularity bias, diversity, novelty, serendipity
Q. Describe popularity bias and its effect, and discuss the importance of diversity, serendipity and novelty.
Model answer. Popularity bias is the tendency to over-recommend already-popular items because they carry the most interactions — a rich-get-richer feedback loop that starves the long tail and drops coverage and novelty. Diversity = how dissimilar items within a list are (avoids redundancy). Novelty = how unknown / non-obvious an item is to the user. Serendipity = relevant and surprising. They matter because accuracy alone yields obvious, repetitive lists; these qualities drive discovery, long-term satisfaction and catalog coverage.