基于redis的朴素贝叶斯文本分类器
redisbayes的Python项目详细描述
name: | redisbayes |
---|---|
description: | Naïve Bayesian Text Classifier on Redis |
Copyright: | © 2012 Justine Alexandra Roberts Tunney |
license: | MIT |
这是什么?
是垃圾邮件过滤器。我写这篇文章是为了过滤来自高层的垃圾评论 流量论坛网站和它工作得很好。它也可以为你工作:) 它不与任何特定格式(如电子邮件)绑定,只处理原始的 文本。
这可能是您为python找到的唯一一个垃圾邮件过滤库 简单的(170行代码),有效的(30行测试代码),并不糟糕。
安装
从文件夹:
sudo python setup.py install
来自芝士店:
sudo pip install redisbayes
来自Git:
sudo pip install git+git://github.com/jart/redisbayes.git
基本用法
import redis, redisbayes rb = redisbayes.RedisBayes(redis=redis.Redis()) rb.train('good', 'sunshine drugs love sex lobster sloth') rb.train('bad', 'fear death horror government zombie god') assert rb.classify('sloths are so cute i love them') == 'good' assert rb.classify('i fear god and love the government') == 'bad' print rb.score('i fear god and love the government') rb.untrain('good', 'sunshine drugs love sex lobster sloth') rb.untrain('bad', 'fear death horror government zombie god')