我正在使用python / django构建一个网站,并希望预测用户提交的内容是有效还是垃圾邮件。
用户对提交内容的接受率如此网站一样。
用户可以审核其他用户的提交内容;这些调节后来由管理员进行元模式化。
鉴于此:
如何预测A发布垃圾邮件的可能性?
编辑:我制作了一个模拟这种情况的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)
运行脚本会给我输出:
这里的概率是否合理?这是模拟场景的正确方法吗?
答案 0 :(得分:5)
答案 1 :(得分:2)
可以使用bayesean分类来检测垃圾邮件,并根据修改结果选择垃圾邮件和火腿的训练集。结果也可能由用户接受的帖子率加权。
垃圾邮件概率很高的结果可以推送到审核工作流程(如果您有专门的审核人)。同样,可以将以前适度的结果样本提交到元审核工作流程中,以获得对分类质量的看法(即,我们得到了不可接受的高误报和否定率)。
最后,用户可能会抱怨发布不公平的“申诉”也可能会将帖子推送到元审核工作流程中。如果用户有上诉拒绝或过高的上诉率(可能是DOS攻击的尝试),他们的帖子可能会在上诉工作流程中被逐渐降低优先级。
答案 2 :(得分:-1)
我们更经验地去做。
我们发现垃圾邮件的最佳指标之一是帖子/评论中的外部链接数量,因为垃圾邮件的重点是让你去某个地方买东西和/或制作友好的googlebot认为链接页面更有趣。
我们对未注册用户的一般规则是:1个链接可能正常,2个是80%+可能是垃圾邮件,3个或更多,他们是干杯。我们保留一个主要域名列表,这些域名出现在被拒绝的帖子中,即使在1或2个链接器中也会成为触发器。你也可以使用RBL,但要小心,因为它们可能非常严苛。
这个简单的东西可能不适合你,但它大大减轻了我们的主持人的负担,我们没有真正的人类抱怨。