Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bayesian Rating

$avg_num_votes = 18; // Average number of votes in all products
 $avg_rating = 3.7; // Average rating for all products
$this_num_votes = 6; // Number of votes for this product
 $this_rating = 4; // Rating for this product


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

echo round($bayesian_rating); // 3

What is the significance of 3? What is the highest possible rating?

like image 935
Ryan Avatar asked Sep 24 '26 08:09

Ryan


2 Answers

you're comparing the ratings for this product against the ratings in all products, so your answer is a rating. If $avg_rating and $this_rating are 3.7 and 4 out of 10, then your answer is out of 10. If it's out of 5, then your answer is out of 5. $bayesian_rating, $avg_rating, and $this_rating are all comparable.

like image 73
Bob Baddeley Avatar answered Sep 26 '26 01:09

Bob Baddeley


Well, working out your math:

((18 * 3.7) + (6 * 4)) / (18 + 6)
(66.6 + 24) / (24)
90.6 / 24
3.775

So it's 3 out of 1...

like image 43
Marc B Avatar answered Sep 26 '26 02:09

Marc B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!