用户有一个类似于此网站的提交接受率。
用户可以审核其他用户的提交;这些审核稍后由管理员进行元审核。
鉴于此:
- 注册用户A提交了一些东西,其提交接受率为60%。
- 用户B将A的帖子审核为有效提交。但是,用户B70%的时间都是错误的。
- 用户C将A的帖子审核为垃圾邮件。用户C通常是正确的。如果用户C说某个东西是垃圾邮件/不是垃圾邮件,则80%的时间是正确的。
编辑:我制作了一个Python脚本来模拟这种情况:
#!/usr/bin/env python
import random
def submit(p):
"""Return 'ham' with (p*100)% probability"""
return 'ham' if random.random() < p else 'spam'
def moderate(p, ham_or_spam):
"""Moderate ham as ham and spam as spam with (p*100)% probability"""
if ham_or_spam == 'spam':
return 'spam' if random.random() < p else 'ham'
if ham_or_spam == 'ham':
return 'ham' if random.random() < p else 'spam'
NUMBER_OF_SUBMISSIONS = 100000
USER_A_HAM_RATIO = 0.6 # Will submit 60% ham
USER_B_PRECISION = 0.3 # Will moderate a submission correctly 30% of the time
USER_C_PRECISION = 0.8 # Will moderate a submission correctly 80% of the time
user_a_submissions = [submit(USER_A_HAM_RATIO) \
for i in xrange(NUMBER_OF_SUBMISSIONS)]
print "User A has made %d submissions. %d of them are 'ham'." \
% ( len(user_a_submissions), user_a_submissions.count('ham'))
user_b_moderations = [ moderate( USER_B_PRECISION, ham_or_spam) \
for ham_or_spam in user_a_submissions]
user_b_moderations_which_are_correct = \
[i for i, j in zip(user_a_submissions, user_b_moderations) if i == j]
print "User B has correctly moderated %d submissions." % \
len(user_b_moderations_which_are_correct)
user_c_moderations = [ moderate( USER_C_PRECISION, ham_or_spam) \
for ham_or_spam in user_a_submissions]
user_c_moderations_which_are_correct = \
[i for i, j in zip(user_a_submissions, user_c_moderations) if i == j]
print "User C has correctly moderated %d submissions." % \
len(user_c_moderations_which_are_correct)
i = 0
j = 0
k = 0
for a, b, c in zip(user_a_submissions, user_b_moderations, user_c_moderations):
if b == 'spam' and c == 'ham':
i += 1
if a == 'spam':
j += 1
elif a == "ham":
k += 1
print "'spam' was identified as 'spam' by user B and 'ham' by user C %d times." % j
print "'ham' was identified as 'spam' by user B and 'ham' by user C %d times." % k
print "If user B says it's spam and user C says it's ham, it will be spam \
%.2f percent of the time, and ham %.2f percent of the time." % \
( float(j)/i*100, float(k)/i*100)
运行脚本后,我得到了以下输出:
- 用户A提交了100000个内容。其中60194个是“正常”。
- 用户B正确审核了29864个内容。
- 用户C正确审核了79990个内容。
- “垃圾邮件”被用户B识别为“垃圾邮件”,而被用户C识别为“正常”的次数为2346次。
- “正常邮件”被用户B识别为“垃圾邮件”,而被用户C识别为“正常”的次数为33634次。
- 如果用户B认为它是垃圾邮件,而用户C认为它是正常邮件,则有6.52%的概率为垃圾邮件,有93.48%的概率为正常邮件。
这里的概率合理吗?这是否是模拟情景的正确方式?