【问题标题】:Apply Bayesian average in a NON 5-star rating system在非 5 星评级系统中应用贝叶斯平均值
【发布时间】:2012-02-15 21:30:56
【问题描述】:

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

here 中列出的方法依赖于贝叶斯平均值:

$bayesian_rating = ( ($avg_num_votes * $avg_rating) + ($this_num_votes * $this_rating) ) / ($avg_num_votes + $this_num_votes);

就我而言,没有$avg_rating,因为它不是一个 5 星级系统,它永远不会存在,喜欢、不喜欢和评论的数量总是在增加,因此我需要注意列表的真实表示.

here 中的解决方案不足以决定方法。

如果我想应用数学方法,最好的解决方案是什么?

编辑添加: 参考。 @Ina , 点赞数乘以 5 就可以体现五星系统, 是五星系统中的最高值。

回到代码,在添加了一些额外的变量来处理(喜欢、不喜欢、评论数量、添加到购物篮的次数)之后,我不确定我可以填写 $avg_rating 和 @ 987654327@与?

这是目前为止的代码:

// 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);   

【问题讨论】:

    标签: php statistics ranking rating bayesian


    【解决方案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 之间有意义的分数,那么你可以通过除以篮子和评论增加的权重来标准化。

    【讨论】:

    • 你的意思是$total_num_positive_votes = total likes / (total likes + total dislikes) 吗?那么其他标准(例如评论数量)呢? $bayesian_rating 中的哪个位置?
    • 否:total_num_positive_votes 只是总喜欢。 total_num_votes 是总喜欢 + 总不喜欢 贝叶斯评级不考虑给出的评论数量。我不确定如何添加它,您能否更详细地描述您的问题?据我所知,您有一个产品列表,每个产品都有一定数量的投票(正面或负面)和一些评论(中性)。
    • 感谢您的快速回复。事实上,这个产品列表可以添加到购物篮、喜欢、不喜欢和评论。我正在寻找的是一种算法,它将考虑 all 这些变量的这些计数并将它们添加到$bayesia_rating 以获得一定的 weight 这将有助于以“有意义”的方式对列表进行排序,就像贝叶斯方法在 5 启动系统中所做的那样。
    • 我已经相应地更新了我的问题,我不确定$avg_rating$this_rating 的值,我发布的代码是否会标准化您在答案中包含的权重?感谢您的帮助。
    • 我已经为您阐明了导致最终答案的变量。
    猜你喜欢
    • 2015-04-09
    • 2011-03-10
    • 1970-01-01
    • 1970-01-01
    • 2012-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多