我期待应用贝叶斯方法来确定列表的优先顺序,该列表可以考虑喜欢,不喜欢和审核计数的数量。
here中列出的方法依赖于贝叶斯平均值:
$bayesian_rating = ( ($avg_num_votes * $avg_rating) + ($this_num_votes * $this_rating) ) / ($avg_num_votes + $this_num_votes);
在我的情况下,没有$avg_rating
,因为它不是一个五星系统,它永远不会存在,喜欢,不喜欢和评论的数量总是递增,因此我需要照顾真正的代表性上市。
here中的解决方案不足以决定方法。
如果我想应用数学方法,最好的解决方案是什么?
编辑添加: 参考。 @Ina,如果我将喜欢乘以5,可以反映5星系统,这使得它在5星系统中具有最高值。
回到代码后,添加一些额外的变量来处理(喜欢,不喜欢,评论次数,添加到购物篮的次数),我不确定我可以填写$avg_rating
和$this_rating
与?
以下是目前的代码:
// these values extracted from the database
$total_all_likes = 10; //total likes of all the products
$total_all_dislikes = 5; //total dislikes of all the products
$total_all_reviews = 7; //total reviews of all the products
$total_all_addedToBasket = 2; //total of products that has been added to basket for all the users
$total_all_votes = ($total_all_likes *5) + $total_all_dislikes; //total of likes and dislikes
$total_all_weight = $total_all_votes + $total_all_reviews + $total_all_addedToBasket; //total interactions on all the products
$total_all_products = 200; //total products count
//Get the average
$avg_like = ($total_all_likes*5)/$total_all_votes; //Average of likes of all the votes
$avg_dislike = $total_all_dislikes/$total_all_votes; //Average of dislikes of all the votes
$avg_reviews = $total_all_reviews/$total_all_products; //Average of reviews of all the products
$avg_addedToBasket = $total_all_addedToBasket/$total_all_products; //Average of added to basket count of all the products
$avg_weight = $avg_like + $avg_dislike + $avg_reviews + $avg_addedToBasket; //Total average weight
//New product, it has not been liked, disliked, added to basket or reviewed
$this_like = 0 *5;
$this_dislike = 0;
$this_votes = $this_like + $this_dislike;
$this_review = 0;
$this_addedToBasket = 0;
$this_weight = $this_votes + $this_review + $this_addedToBasket;
//$avg_rating
//$this_rating
$bayesian_rating = (($avg_weight * $avg_rating) + ($this_weight * $this_rating) ) / ($avg_weight + $this_weight);
答案 0 :(得分:1)
而不是五星系统,你有一个二进制系统。人们要么“喜欢”要么“不喜欢”。因此,评级自然是0到1之间的数字,由下式计算:
likes / (likes + dislikes)
您不需要乘以5来模仿5 *等级系统。
然后您的代码变为:
$avg_rating = $total_all_likes / ($total_all_likes + $total_all_dislikes)
$this_rating = $this_like / ($this_like + $this$total_num_positive_votes / $total_num_votes) // Check you're not dividing by 0
$bayesian_rating = (($avg_num_votes * $avg_rating) + ($this_num_votes * $this_rating) ) / ($avg_num_votes + $this_num_votes);
如果您还想考虑“篮子”和“评论”的数量,您可以简单地将它们视为“重量”
$this_weight = $this_addedToBasket + $this_votes + $this_review;
$avg_votes = $total_all_votes / $total_all_products;
$avg_weight = $avg_addedToBasket + $avg_votews + $avg_reviews;
$bayesian_rating = (($avg_weight * $avg_rating) + ($this_weight * $this_rating) ) / ($avg_weight + $this_weight);
这将为您提供良好的相对排名,但是如果您希望在0和1之间看到有意义的分数,那么您可以通过将篮子和评论添加的权重除去来进行标准化。