3

我期待着应用贝叶斯方法来优先考虑可以考虑喜欢、不喜欢和评论计数的列表。

此处列出的方法依赖于贝叶斯平均值:

$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);   
4

1 回答 1

1

你有一个二进制系统,而不是一个 5 星系统。人们要么“喜欢”,要么“不喜欢”。因此,评级自然是一个介于 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 之间有意义的分数,那么你可以通过除以篮子和评论增加的权重来进行标准化。

于 2012-02-15T21:47:03.120 回答