Ognjen Regoje bio photo

MY NAME IS
Ognjen Regoje
BUT YOU CAN CALL ME OGGY


I make things that run on the web (mostly).
More /ABOUT me.

me@ognjen.io Twitter LinkedIn Github

Formula for weighing ratings by their count

I experimented with sorting items by their average rating and the number of ratings. I wanted to have products with higher number of ratings appear before ones with equal average rating.

There are a couple of simple ways to do this:

  1. Sort by average rating, then by number of ratings. It works but I think an item rated 4.5 by a thousand people is better than an item rated 4.6 by ten people.

  2. Show the number of ratings either in parentheses as a real number or some kind of visual indicator. This offloads the processing to the user. Also works but is kind of inelegant.

I wanted to achieve this using only the average rating and the number of ratings. I didn’t want to have to use dates, or counts in buckets, or averages over time.

In the end, this formula calculates a decent weighted average:

a+a×(ln n)×1.6/100

where a is the average rating and n the number of ratings.

Some examples:

a n weighted average
4.9 10 5.01
4.6 100 4.81
4.5 100 4.70
4.6 10 4.70
4.2 10000 4.58
3.6 10000 3.93

Overall I think that’s a decent result but I’ve yet to test in production.

Update

After some tweaking this still seems like a decent solution. One addition though: introduce a coefficient that’s based on the average number of ratings an item has.

For instance, if the average number of ratings is 10 there wont be enough difference between 8 and 16 ratings even though that’s twice the number of ratings. The lower the average number of ratings is the higher the coefficient should be. On a side project where the average number of ratings was ten I used 1.6.

Updated formula:

a+a×(ln n)×1.6/100

#product #technical