Recommendation Systems

A recommendation system predicts what a user will want — a film, product, or song — from patterns in past behavior, and surfaces it automatically.

Published Updated

On this page

Definition

A recommendation system predicts what a user will want next — a film, a product, a song — from patterns in how that user and similar users have behaved, and surfaces those items automatically. It is the engine behind Netflix's homepage, Amazon's "Customers who bought this item also bought" row, and YouTube's up-next queue: rather than wait for you to search, it ranks a catalog of thousands or millions of items and pushes the handful you are most likely to click, watch, or buy to the top.

The whole problem can be drawn as a single table. Put every user on a row and every item on a column, and fill in the cell where they meet with a rating, a click, or a purchase. That table — the user–item interaction matrix — is the object a recommender works on, and its defining property is that almost every cell is blank, because no one has watched, bought, or rated more than a tiny fraction of everything on offer. A recommendation is simply an educated guess at the value of a blank cell: if we had asked this user about this item, how high would they have scored it? Everything else is machinery for filling in that table well, and this is a Machine Learning problem because the guesses are learned from the cells that are filled rather than written by hand.

How It Works

Start with how empty the matrix really is. The dataset Netflix released for its public contest held 100,480,507 ratings covering 480,189 users and 17,770 films. A full table of that shape has 480,189 × 17,770 ≈ 8.53 billion cells, so the 100 million observed ratings fill only about 1.2% of it — roughly 98.8% of the matrix is blank. Predicting those blanks is the entire job, and doing it by looking up "similar users" one at a time does not scale to billions of cells.

The dominant trick is matrix factorization. Instead of storing the 8.53-billion-cell table, you assume each user and each item can be described by a short vector of hidden numbers called latent factors — imagine one axis that quietly measures "how much action versus romance" and another for "mainstream versus arthouse," except the system discovers these axes itself rather than being told what they mean. You then learn a user matrix (480,189 rows × k factors) and an item matrix (17,770 rows × k factors) whose product reconstructs the observed ratings as closely as possible. With k = 50 factors that is (480,189 + 17,770) × 50 ≈ 24.9 million numbers — about 340× smaller than the full 8.53-billion-cell table — and, crucially, the two small matrices multiply out to a value for every cell, including the blank ones. These learned factor vectors are exactly the Embedding idea applied to users and items.

Predicting a single blank cell is then one dot product: multiply the target user's factor vector by the target item's factor vector and sum. If the user's vector says "loves action, dislikes romance" and the item's vector says "very action, little romance," the two align and the predicted score is high; if they point in opposite directions, it is low. Learning the vectors that make these dot products match the ratings we do have — while staying simple enough to generalize to the ratings we don't — is what training a collaborative-filtering model actually optimizes. The same "find things that point the same way" logic can be run over users directly, which is why grouping look-alike users with Clustering is a classic first cut at the problem.

Types

The field has one genuinely standard taxonomy, and these three terms are worth knowing because practitioners use them daily.

Collaborative filtering recommends based on behavior alone. It never reads what an item is; it only notices that people who liked the things you liked also liked something you haven't seen, and recommends that. There are two symmetric views: user-based (find users similar to you, recommend what they rated highly) and item-based (find items similar to the ones you rated highly, recommend those). Matrix factorization is the scalable, learned version of the same idea. Its great strength is that it needs no metadata at all — it works equally well for movies, socks, and songs — and its great weakness is the cold-start problem below.

Content-based filtering recommends based on item features instead of crowd behavior. It builds a profile from the attributes of things you liked — a film's genre and cast, an article's text, a product's category — and finds new items whose features match. Its advantage is the mirror image of collaborative filtering's weakness: a brand-new item with zero ratings can still be recommended the moment its metadata exists, because it is compared on features, not on interactions it does not yet have. The cost is a tendency toward a narrow "filter bubble," since it can only ever recommend more of what you have already shown you like.

Hybrid systems combine the two, and this is what essentially every large production recommender actually is. A hybrid can use content features to survive cold start and collaborative signals to capture the subtle "people like you" patterns that no feature list encodes. Netflix's homepage and YouTube's ranking are hybrids that fold in dozens of signals — recent behavior, item metadata, context like time of day and device — rather than any single one of the three pure methods.

Real-World Applications

The Netflix Prize (2006–2009) is the milestone that made recommendation accuracy a public sport. Netflix put up $1,000,000 for the first team to beat its in-house recommender, Cinematch, by 10%. Accuracy was measured as root-mean-square error (RMSE) between predicted and actual 1-to-5-star ratings: Cinematch scored 0.9514 on the contest's quiz set, and a 10% improvement meant reaching 0.8563 (0.9514 × 0.90 ≈ 0.8563). What makes the prize a good lesson is how small that target looks in human terms — the gap between the two scores is just 0.0951 of a star on a five-star scale, and closing it took the field three years. The grand prize was awarded in September 2009 to the team BellKor's Pragmatic Chaos, whose winning entry was a blend of many models — living proof that hybrids beat any single method.

Amazon's item-to-item collaborative filtering is the other canonical deployment, described by Linden, Smith, and York in a 2003 IEEE Internet Computing paper. Their key move was to precompute similarities between items rather than between customers. Finding users similar to a given user is expensive when, as the paper notes, "Amazon.com has more than 29 million customers" (as of that 2003 paper); comparing items instead lets the system serve "high-quality recommendations in real time" and "scale to massive data sets" of tens of millions of customers and millions of catalog items. That algorithm is what powers the familiar "Customers who bought this item also bought" row.

Streaming and video feeds are where recommenders now drive the majority of consumption. Netflix's homepage, Spotify's Discover Weekly, and YouTube's up-next queue each rank an enormous catalog per user, per session, blending collaborative and content signals in deep models. Modeling the user–item graph directly with Graph Neural Networks — where users and items are nodes and interactions are edges — has become a common ingredient in these systems, because it captures multi-hop patterns ("friends of friends liked this") that a flat matrix does not.

Challenges

The cold-start problem is the failure that defines the field's limits. A brand-new user has rated nothing, and a newly added item has been rated by no one, so pure collaborative filtering has no similar-behavior signal to place either of them — the corresponding row or column of the matrix is entirely blank, and a dot product against an untrained factor vector is meaningless. This is why hybrids exist: a new film can still be recommended from its genre, cast, and description (content features) until enough people rate it for collaborative signals to take over. Ignore cold start and every new item on your platform is invisible until it somehow gets popular on its own — a chicken-and-egg trap.

Feedback loops and popularity bias are subtler and worse. A recommender is trained on the very clicks it caused, so items it shows often get more interactions, which makes the model recommend them even more, while the long tail is starved of the exposure it would need to prove itself. Left unchecked the system narrows toward a few blockbusters and its own past behavior, which is why production teams deliberately inject diversity and exploration rather than always serving the single highest-predicted item.

Sparsity and scale are the ever-present engineering constraint. The 98.8%-empty matrix above is typical, and real catalogs are far larger than Netflix's 17,770 films; a system may need to score millions of candidate items for each of hundreds of millions of users within a few milliseconds. That budget is why brute-force similarity is out and why the factorization and retrieval techniques below exist.

The clearest shift is from scoring every item to retrieving candidates by nearest-neighbor search. Modern "two-tower" systems encode users and items into the same embedding space and, at serving time, use approximate Vector Search to pull the few hundred closest item vectors to a user's vector out of millions in milliseconds — turning recommendation into a geometry problem rather than a full matrix scan. A slower reranking model then orders that short list.

The second shift is treating a user's history as a sequence rather than a bag of ratings. Sequential recommenders such as SASRec and BERT4Rec apply the attention mechanism from language models to a user's ordered interaction stream, predicting the next item the way a language model predicts the next word — which captures that what you want right now depends on what you just watched, not only on your all-time averages.

Code Example

Item-based collaborative filtering in a dozen lines: given a small user–item rating matrix, predict one blank cell by finding the items most similar to the target item (via cosine similarity over the users who rated both) and averaging the target user's ratings on those neighbors, weighted by similarity. This is the core of Amazon's item-to-item idea on a toy scale.

import numpy as np

# Rows = 6 users, columns = 5 films. Films 0-2 are action, 3-4 are romance.
# 0 marks a rating we have NOT observed. Users 0-2 favour action, 3-5 romance.
R = np.array([
    [5, 5, 4, 1, 1],
    [4, 5, 5, 1, 2],
    [5, 4, 0, 2, 1],   # user 2 has not rated film 2 -> we predict it
    [1, 2, 1, 5, 5],
    [2, 1, 1, 4, 5],
    [1, 1, 2, 5, 4],
], dtype=float)

def item_similarity(col_i, col_j):
    both = (col_i > 0) & (col_j > 0)          # users who rated BOTH films
    a, b = col_i[both], col_j[both]
    return float(a @ b / (np.linalg.norm(a) * np.linalg.norm(b)))

u, i, k = 2, 2, 2                             # user 2, film 2, 2 nearest films
cands = [(item_similarity(R[:, i], R[:, j]), R[u, j])
         for j in range(R.shape[1]) if j != i and R[u, j] > 0]
cands.sort(reverse=True)                      # most similar films first
top = cands[:k]
sims = np.array([s for s, _ in top])
ratings = np.array([r for _, r in top])
pred = (sims @ ratings) / sims.sum()
print("k nearest films' similarities to film 2:", np.round(sims, 2))
print("user 2's own ratings for those films:   ", ratings)
print(f"predicted rating for the empty cell:    {pred:.2f}")

Running it prints:

k nearest films' similarities to film 2: [0.97 0.96]
user 2's own ratings for those films:    [4. 5.]
predicted rating for the empty cell:    4.50

The two films most similar to film 2 are the other two action films (similarity 0.97 and 0.96), user 2 rated them 4 and 5, and the weighted average predicts 4.50 for the blank cell — the system has correctly inferred that an action fan will rate another action film highly, without ever being told what "action" means. That last point is the whole magic of collaborative filtering: the genres were never in the data, only the ratings were, and the structure fell out of the numbers.

Frequently Asked Questions

Collaborative filtering recommends items based on the behavior of similar users or items; content-based filtering recommends items whose features resemble what you already liked; and hybrid systems combine both. Almost every large production system is a hybrid.
A brand-new user or a newly added item has no interaction history, so collaborative filtering has no similar-behavior signal to place it. The usual fix is to fall back on content features or demographics until enough interactions accumulate.
A public contest (2006–2009) offering $1,000,000 to the first team to improve the accuracy of Netflix's Cinematch recommender by 10%, measured as root-mean-square error. It was won in September 2009 by the team BellKor's Pragmatic Chaos.
It approximates the giant, mostly-empty user–item rating matrix as the product of two much smaller matrices of latent factors — one per user, one per item. Multiplying a user's factors by an item's factors predicts the rating for a cell that was never observed.
Collaborative filtering ignores what an item actually is and learns purely from who interacted with what; content-based filtering reads the item's own features (genre, text, tags). The first needs a crowd, the second needs good metadata.

Continue Learning

Explore our use-case guides and prompts to deepen your AI knowledge.