A naive popularity ranking simply sorts items by average rating, but this unfairly favors items with very few ratings. An item with a single 10/10 rating would outrank a consistently 9.5-rated item with thousands of reviews. The Bayesian weighted rating (used by IMDB's Top 250) solves this by blending the item's average with the global mean, weighted by the number of votes.
Given a list of items with their average rating and vote count, a minimum vote threshold m, and the global mean rating C, compute the weighted rating for each item.
where R is the item's average rating, v is its vote count, m is the minimum vote threshold, and C is the global mean rating.
Input:
items = [(8.5, 1000), (9.2, 50)], min_votes = 100, global_mean = 7.5
Output:
[8.409, 8.067]
Item 0 has many votes so its WR stays close to 8.5. Item 1 has few votes (50 < 100) so it is pulled strongly toward the global mean of 7.5, dropping from 9.2 to 8.067.
Input:
items = [(10.0, 1)], min_votes = 100, global_mean = 5.0
Output:
[5.0495]
With only 1 vote against a threshold of 100, the weighted rating is almost entirely the global mean: (1/101)*10 + (100/101)*5 = 5.0495.
For each (avg_rating, num_votes) pair, compute: (num_votes / (num_votes + min_votes)) * avg_rating + (min_votes / (num_votes + min_votes)) * global_mean.
When num_votes is 0, the formula gives (0/(0+m))*R + (m/m)*C = C, which is exactly the global mean. This is the correct behavior - no votes means we fall back to the prior.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
A naive popularity ranking simply sorts items by average rating, but this unfairly favors items with very few ratings. An item with a single 10/10 rating would outrank a consistently 9.5-rated item with thousands of reviews. The Bayesian weighted rating (used by IMDB's Top 250) solves this by blending the item's average with the global mean, weighted by the number of votes.
Given a list of items with their average rating and vote count, a minimum vote threshold m, and the global mean rating C, compute the weighted rating for each item.
where R is the item's average rating, v is its vote count, m is the minimum vote threshold, and C is the global mean rating.
Input:
items = [(8.5, 1000), (9.2, 50)], min_votes = 100, global_mean = 7.5
Output:
[8.409, 8.067]
Item 0 has many votes so its WR stays close to 8.5. Item 1 has few votes (50 < 100) so it is pulled strongly toward the global mean of 7.5, dropping from 9.2 to 8.067.
Input:
items = [(10.0, 1)], min_votes = 100, global_mean = 5.0
Output:
[5.0495]
With only 1 vote against a threshold of 100, the weighted rating is almost entirely the global mean: (1/101)*10 + (100/101)*5 = 5.0495.
For each (avg_rating, num_votes) pair, compute: (num_votes / (num_votes + min_votes)) * avg_rating + (min_votes / (num_votes + min_votes)) * global_mean.
When num_votes is 0, the formula gives (0/(0+m))*R + (m/m)*C = C, which is exactly the global mean. This is the correct behavior - no votes means we fall back to the prior.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number