开发者

Bayesian Rating

开发者 https://www.devze.com 2023-03-19 05:10 出处:网络
$avg_num_votes = 18; // Average number of votes in all products $avg_rating = 3.7; // Average rating for all products
$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 * $av开发者_C百科g_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?


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.


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消