威尔逊得分没有考虑到负面投票?

时间:2014-03-22 02:50:56

标签: ruby-on-rails ruby algorithm

我正在使用威尔逊评分算法(下面的代码),并意识到它不会反对否定投票。

示例:

Upvotes  Downvotes  Score
1        0          0.2070
0        0          0
0        1          0 <--- this is wrong 

这是不正确的,因为负净票数应该得分较低。

def calculate_wilson_score(up_votes, down_votes)
  require 'cmath'
  total_votes = up_votes + down_votes
  return 0 if total_votes == 0

  z = 1.96
  positive_ratio = (1.0*up_votes)/total_votes
  score = (positive_ratio + z*z/(2*total_votes) - z * CMath.sqrt((positive_ratio*(1-positive_ratio)+z*z/(4*total_votes))/total_votes))/(1+z*z/total_votes)
  score.round(3)
end

更新

以下是维基百科上Wilson scoring confidence interval的说明。

1 个答案:

答案 0 :(得分:0)

威尔逊得分较低的置信区间肯定会考虑负面投票,尽管较低的置信区间不会低于零,这是完全正常的。排名项目的这种近似通常用于识别最佳评级列表上排名最高的项目。因此,当查看排名最低的项目时,它可能具有不合需要的属性,这是您所描述的类型。

这种排名项目的方法由Evan Miller在a post on how not to sort by average rating中推广,尽管他后来stated

  

我之前提出的解决方案 - 使用平均值周围的置信区间的下限 - 是计算机程序员所说的黑客攻击。它不是因为它是一个普遍最优的解决方案,而是因为它大致对应于我们在最佳评级列表顶部看到的内容的直观感觉:给出了最坏概率的项目,给出数据。

如果您真的有兴趣分析列表中排名最低的项目,我建议使用上限置信区间,或使用贝叶斯评级系统,如:https://stackoverflow.com/a/30111531/3884938

相关问题