Python实现了威尔逊的评分区间? [英] Python implementation of the Wilson Score Interval?
本文介绍了Python实现了威尔逊的评分区间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
阅读如何不至按平均评分后,我很好奇,如果任何人有一个Python实现一个较低的约束威尔逊的得分置信区间伯努利参数?
After reading How Not to Sort by Average Rating, I was curious if anyone has a Python implementation of a Lower bound of Wilson score confidence interval for a Bernoulli parameter?
推荐答案
reddit的使用威尔逊评分区间征求意见的排名,解释和Python实现,可以发现的这里
Reddit uses the Wilson score interval for comment ranking, an explanation and python implementation can be found here
#Rewritten code from /r2/r2/lib/db/_sorts.pyx
from math import sqrt
def confidence(ups, downs):
n = ups + downs
if n == 0:
return 0
z = 1.0 #1.44 = 85%, 1.96 = 95%
phat = float(ups) / n
return ((phat + z*z/(2*n) - z * sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n))
这篇关于Python实现了威尔逊的评分区间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文