Recommendation systems power a huge share of the modern internet’s engagement — from “customers also bought” to entire content feeds — and the two classic underlying approaches are genuinely worth understanding at a basic level.
# Collaborative filtering: recommend based on what SIMILAR USERS liked
# (doesn't need to know anything about the item's actual content)
user_ratings = {
'alice': {'movie_a': 5, 'movie_b': 3, 'movie_c': 4},
'bob': {'movie_a': 4, 'movie_b': 2, 'movie_d': 5},
'carol': {'movie_a': 5, 'movie_c': 5, 'movie_d': 4},
}
# Find users with SIMILAR rating patterns to Alice (e.g. via cosine similarity),
# then recommend items THOSE similar users liked that Alice hasn't rated yet
# -> e.g. recommend movie_d to Alice, since Bob and Carol (similar tastes) both liked it
Collaborative Filtering vs Content-Based Filtering
- Collaborative filtering — “users like you also liked this” — needs no knowledge of the item’s actual content, but suffers a genuine “cold start” problem for brand-new items with no ratings yet
- Content-based filtering — “this is similar in content/features to things you’ve liked before” — works fine for new items with no ratings, but tends to over-narrow recommendations toward things very similar to what you already engage with
Why Modern Systems Combine Both
Most production recommendation systems blend collaborative and content-based signals together, plus increasingly deep learning models trained on rich user and item embeddings — genuinely combining collaborative filtering’s ability to surface surprising, cross-category recommendations with content-based filtering’s ability to meaningfully handle new items that have no rating history yet.