Search code examples
phpmysqlalgorithmrating

PHP/MySQL - algorithm for "Top Rated"


So I just built a star-rating system and and trying to come up with an algorithm to list the "Top Rated" items. For simplicity, here are the columns:

item_name
average_rating (a decimal from 1 to 5)
num_votes

I'm trying to determine the "sweet spot" between number of votes and rating. For example...

  • An item rated (4.6 / 20 votes) should be higher on the list than an item that's (5.0 / 2 votes)
  • An item rated (2.5 / 100 votes) should be below an item that's (4.5 / 2 votes)

So in other words, num_votes plays a factor in what's "Top".

Anyone know of an algorithm that is pretty good at determining this "sweet spot"?

Thanks in advance.


Solution

  • here's another, statistically sound good way: http://www.thebroth.com/blog/118/bayesian-rating