Skip to content
Machine Learning
Recommender Systems 9 min read

Popularity & Weighted Ratings

Build your first recommender — a "top charts" list that ranks movies fairly by blending average rating with vote count using the IMDB weighted-rating formula.

Download notebook Open Google ColabIn Colab: File → Upload notebook → pick the downloaded file.

Every product you use — Netflix, YouTube, Spotify, Tokopedia — spends enormous effort answering one question: out of thousands of items, which ten should we show this person right now? That's the recommendation problem, and this module builds the three classic answers to it from scratch. We start with the simplest one: recommend what's popular — but do it fairly.

The recommendation problem, and three ways to solve it

A recommender system ranks items for a user. The three classic families differ in what information they use to build that ranking:

  • Popularity / demographic filtering — recommend what people in general like: "Top 50 movies of the year". No personalization; everyone sees the same list. It only needs item statistics (ratings, vote counts, genre, year).
  • Content-based filtering — recommend items similar to what you already liked: "More like Toy Story". It compares item attributes — genre, cast, synopsis — so it needs a good description of each item.
  • Collaborative filtering — recommend what people with similar taste liked: "Users who watched this also watched…". It ignores item attributes entirely and learns purely from behavior.

They form a ladder of personalization, and real systems combine all three. This lesson climbs the first rung.

Why the raw average rating fails

The obvious popularity ranking — sort by average rating — has a famous flaw. Suppose one film holds a 9.6 average from 3 votes and another holds an 8.7 from 26,000 votes. Which is actually better? Almost certainly the second: three enthusiastic friends can produce a 9.6, but 26,000 strangers agreeing on 8.7 is strong evidence. A raw sort can't tell the difference. Watch it happen:

Python — runs in your browser

Two movies nobody has heard of — Midnight Static (3 votes) and The Lost Reel (12 votes) — beat The Shawshank Redemption. The average rating alone answers "how much did the people who voted like it?" but ignores "how many people is that opinion based on?"

The IMDB weighted rating

IMDB's classic fix blends each movie's own average with the global average, weighted by how many votes the movie has:

WR = (v / (v + m)) · R + (m / (v + m)) · C

  • v — number of votes for the movie (vote_count)
  • R — the movie's own average rating (vote_average)
  • C — the mean rating across all movies
  • m — the minimum votes required to be taken seriously (a tuning knob)

Read it as a tug-of-war. When v is huge compared to m, the first fraction approaches 1 and WR ≈ R — the movie has earned the right to its own score. When v is tiny, the second fraction dominates and WR ≈ C — the movie is pulled toward "just average" until it collects more evidence. Statisticians call this shrinkage: shrink unreliable estimates toward the global mean.

How do you pick m? A common recipe is a quantile of the vote counts — e.g. "you need more votes than 70% of the catalog". Let's build the fair chart:

Python — runs in your browser

The 3-vote wonder collapses from 9.6 down to roughly the global mean, while heavily-voted films keep scores close to their true averages. On IMDB's real Top 250, m is set high enough (25,000 votes) that low-evidence movies are also excluded outright — with a real catalog of thousands of films you'd use q=0.90 or higher rather than our small-sample 0.70.

Filter → score → sort

Production popularity shelves usually add a filtering step before scoring: restrict to a genre, a year range, or a runtime window ("Top animated films of the 2010s"), then compute the weighted rating within that slice, then sort. The same three-step recipe — filter, score, sort — powers every "Top 10 in Indonesia today" row you've ever seen.

Where popularity lists shine — and where they stop

Popularity ranking is genuinely useful:

  • Cold start. A brand-new visitor has no history, so personalized methods have nothing to work with. Showing them what's broadly loved is the best available move — this is why logged-out homepages are wall-to-wall charts.
  • Trending shelves. "Popular this week" computed over a recent time window is a strong, cheap signal that requires zero user data.
  • A sanity baseline. Any fancy recommender that can't beat "recommend the most popular items" isn't earning its complexity. Always measure against it.

But the limits are built into the definition:

  • No personalization. Everyone gets the same list. If you love obscure documentaries, the chart still hands you superhero blockbusters.
  • Popularity bias / feedback loops. Popular items get recommended, which makes them more popular, which keeps them recommended. Niche gems stay buried, and the catalog's "long tail" never gets exposure.

Fixing the first limitation is the job of the next two lessons.

Check your understanding

4 questions · free
  1. Q1.A film has a 9.8 average from 4 votes. Why shouldn't it top the chart?

  2. Q2.In WR = (v/(v+m))·R + (m/(v+m))·C, what happens as a movie's vote count v grows far beyond m?

  3. Q3.What does choosing m as the 90th-percentile vote count mean in practice?

  4. Q4.Which situation is the strongest use case for a pure popularity recommender?

Exercise: Tune the evidence threshold

Write a function top_chart(df, q, k=5) that computes the IMDB weighted rating using m = quantile(q) of the vote counts and returns the top k movies. Run it with q = 0.05, q = 0.50, and q = 0.90 on the lesson's movie table. At which setting does Midnight Static (9.6 average, 3 votes) sneak back into the top 5 — and why?

Next up: content-based filtering — turning "you liked Toy Story" into "you might like Finding Nemo" by measuring how similar two movies are.