一个基于内存的可选持久性朴素贝叶斯文本分类器。

simplebayes的Python项目详细描述


基于内存的可选持久性朴素贝叶斯文本分类器。

This work is heavily inspired by the python "redisbayes" module found here:
[https://github.com/jart/redisbayes] and [https://pypi.python.org/pypi/redisbayes]

I've elected to write this to alleviate the network/time requirements when
using the bayesian classifier to classify large sets of text, or when
attempting to train with very large sets of sample data.

生成状态

https://travis-ci.org/hickeroar/simplebayes.svg?branch=masterhttps://img.shields.io/badge/coverage-100%-brightgreen.svg?style=flathttps://img.shields.io/badge/pylint-10.00/10-brightgreen.svg?style=flathttps://img.shields.io/badge/flake8-passing-brightgreen.svg?style=flat

安装

sudo pip install simplebayes

基本用法

importsimplebayesbayes=simplebayes.SimpleBayes()bayes.train('good','sunshine drugs love sex lobster sloth')bayes.train('bad','fear death horror government zombie')assertbayes.classify('sloths are so cute i love them')=='good'assertbayes.classify('i would fear a zombie and love the government')=='bad'printbayes.score('i fear zombies and love the government')bayes.untrain('bad','fear death')assertbayes.tally('bad')==3

缓存使用

importsimplebayesbayes=simplebayes.SimpleBayes(cache_path='/my/cache/')# Cache file is '/my/cache/_simplebayes.pickle'# Default cache_path is '/tmp/'ifnotbayes.cache_train():# Unable to load cache data, so we're training itbayes.train('good','sunshine drugs love sex lobster sloth')bayes.train('bad','fear death horror government zombie')# Saving the cache so next time the training won't be neededbayes.persist_cache()

标记器重写

importsimplebayesdefmy_tokenizer(sample):returnsample.split()bayes=simplebayes.SimpleBayes(tokenizer=my_tokenizer)

许可证

The MIT License (MIT)

Copyright (c) 2015 Ryan Vennell

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java FloatingAction按钮与RecyclerView中的CardView重叠   java如何计算CardLayout中的卡数   从远程系统上传MySQL数据库并访问Java应用程序   java调用堆栈如何处理带或不带返回类型的递归?   Springboot中的java组计数聚集   java如何在javafx textarea中使用richtextfx   获取与Mockito相关的错误时出现Java问题   java如何将JaxRS响应转换为Wiremock响应   Hadoop集群java。net ConnectionException:连接被拒绝错误   java如何加载文件私有文件类型是pem   java在元空间中的提升和加载的类   如何将系统属性传递给从HTML启动的Java小程序   java如何从网页中获取值并在主类中使用它?安卓应用   java在春天,advisor和aspect之间有什么区别?   java如何检测文件是否已重命名?   java消息驱动Bean何时使用