我期待着应用贝叶斯方法来优先考虑可以考虑喜欢、不喜欢和评论计数的列表。
此处列出的方法依赖于贝叶斯平均值:
$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);