在非 5 星级评级系统中应用贝叶斯平均值
我期待应用贝叶斯方法来确定列表的优先级,该列表可以考虑喜欢、不喜欢和评论的数量。
此处列出的方法依赖于贝叶斯平均值:
<代码>$bayesian_ rating = ( ($avg_num_votes * $avg_ rating) + ($this_num_votes * $this_ rating) ) / ($avg_num_votes + $this_num_votes);
就我而言,没有 $avg_ rating
因为它不是一个 5 星级系统,它永远不会存在,喜欢、不喜欢和评论的数量总是增加,因此我需要注意列表的真实表现。
此处中的解决方案不足以决定一种方法。
如果我想应用数学方法,最好的解决方案是什么?
编辑添加: 参考号@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);
I am looking forward to apply the bayesian approach to prioritize a list that could take the number of likes, dislikes and review counts into consideration.
The approach listed in here relies on the bayesian average:
$bayesian_rating = ( ($avg_num_votes * $avg_rating) + ($this_num_votes * $this_rating) ) / ($avg_num_votes + $this_num_votes);
In my case, there are no $avg_rating
since its not a 5-star system, it will never exist, the number of likes, dislikes and reviews always increments therefore i need to take care of the true representation of the listing.
The solution in here was not enough to decide on an approach.
What would the best solution be in case i want to apply a mathematical approach?
Edit added:
Ref. @Ina , it is possible to reflect the 5-star system if i multiply the likes by 5 which makes it with the highest value in a 5-star system.
Getting back to the code, after adding some extra variables to take care of (likes, dislikes, number of reviews, number of times added to basket) , i am not sure the what can i fill the $avg_rating
and $this_rating
with?
Here is the code so far:
// 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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您拥有的不是五星级系统,而是二进制系统。人们要么“喜欢”,要么“不喜欢”。因此,评级自然是 0 到 1 之间的数字,计算公式如下:
您不需要乘以 5 来模仿 5* 评级系统。
然后,您的代码将变为:
如果您还想考虑“购物篮”和“评论”的数量,您可以简单地将它们视为更多“权重”
这将为您提供良好的相对排名,但是如果您希望看到有意义的分数介于 0 和 1 之间,那么您可以通过除以购物篮和评论添加的权重来标准化。
Instead of a 5-star system, you have a binary system. People either 'like' or 'dislike'. The ratings are therefore naturally a number between 0 and 1 calculated by:
You do not need to multiply by 5 to imitate a 5* rating system.
Your code then becomes:
If you want to also take into account the number of 'baskets' and 'reviews' you can simply treat them as more 'weight'
This will give you a good relative ranking, however if you wish to see meaningful scores between 0 and 1, then you can normalise by dividing away the weight added by baskets and reviews.