potts
potts

Reputation: 155

A suitable scoring algorithm for 3 scores

I have several objects, each object should be rated by [q]Quality, [v]Value and [s]Suitability by a user.

Currently I am retrieving the total average of each object by Score = (q+v+s/3) - That said I run into the popular issue where an object with 1 rating of 10,10,10 is rated higher than a object with 3 ratings of 10,9,9 | 9,10,10 | 10,10,8 - Not good!

I want to score each object by a total. Is there any algorithm that would be best suited? The end result will be in a PHP environment. An example could be roughly what Awwwards has currently for each of its websites listed.

I've looked around and can see similar requirements and the Bayesian method being suggested, I'm not sure how this would match my requirements though as the need for knowing a 'minimum'?

Digging around a bit more, I've found this - applied to some SQL would this work? Any issues?

<?php

$avg_num_votes = 17; // Average number of reviews on all objects
$avg_rating = 4.5; // Average review for all objects
$this_num_votes = 17; // Number of reviews on this object
$this_rating = 4; // Review for this object

$bayesian_rating = (($avg_num_votes * $avg_rating) + ($this_num_votes * $this_rating)) / ($avg_num_votes + $this_num_votes);
echo $bayesian_rating;

//(FR) = ((av * ar) + (v × r)) / (av + v)
//(FR) = ((17 * 4.5) + (17 * 4)) / (17 + 17)
//(FR) = (76.5 + 68) / 34
//(FR) = 162.5 / 34
//(FR) = 4.25
?>

Upvotes: 1

Views: 643

Answers (1)

Douglas Zare
Douglas Zare

Reputation: 3316

Laplace smoothing is simple to implement, although you have to choose one parameter. It is what is being called "the Bayesian estimate" or "the Bayesian method" although that is not quite right, and there are many other techniques that more accurately implement Bayesian updating for different choices of prior distributions.

Choose M, called the number of "minimum" ratings by some. Calculate the average rating A over all categories. Give each object M average ratings in addition to the users' ratings. If you change M, this changes how much you trust a small sample. Larger values of M give less credit to small numbers of ratings.

You don't need to adjust this based on having three scores. Call the sum the rating.

For example, suppose the average rating anywhere is 25, you have chosen M=3, and you are comparing one object with 1 rating of 30 to an object with 7 ratings of 27. For the first, you calculate a smoothed rating of (30*1 + 25*3)/(1+3) = 26.25. The smoothed rating of the second is (27*7+25*3)/(7+3) = 26.4. So, the second object would have a slightly higher smoothed rating than the first.

Upvotes: 1

Related Questions