Naive Bayesian Classifier 朴素贝叶斯分类器开源项目

我要开发同款
匿名用户2017年10月24日
109阅读

技术信息

开源地址
https://github.com/muatik/naive-bayes-classifier
授权协议
MIT

作品详情

这是一个非常简单的Pytho库,实现了朴素贝叶斯分类器。

示例代码:

"""Suppose you have some texts of ews ad kow their categories.You wat to trai a system with this pre-categorized/pre-classified texts. So, you have better call this data your traiig set."""from aiveBayesClassifier import tokeizerfrom aiveBayesClassifier.traier import Traierfrom aiveBayesClassifier.classifier import ClassifierewsTraier = Traier(tokeizer.Tokeizer(stop_words = [], sigs_to_remove = ["?!#%&"]))# You eed to trai the system passig each text oe by oe to the traier module.ewsSet =[    {'text': 'ot to eat too much is ot eough to lose weight', 'category': 'health'},    {'text': 'Russia is tryig to ivade Ukraie', 'category': 'politics'},    {'text': 'do ot eglect exercise', 'category': 'health'},    {'text': 'Syria is the mai issue, Obama says', 'category': 'politics'},    {'text': 'eat to lose weight', 'category': 'health'},    {'text': 'you should ot eat much', 'category': 'health'}]for ews i ewsSet:    ewsTraier.trai(ews['text'], ews['category'])# Whe you have sufficiet traied data, you are almost doe ad ca start to use# a classifier.ewsClassifier = Classifier(ewsTraier.data, tokeizer.Tokeizer(stop_words = [], sigs_to_remove = ["?!#%&"]))# Now you have a classifier which ca give a try to classifiy text of ews whose# category is ukow, yet.ukowIstace = "Eve if I eat too much, is ot it possible to lose some weight"classificatio = ewsClassifier.classify(ukowIstace)# the classificatio variable holds the possible categories sorted by # their probablity valueprit classificatio

功能介绍

这是一个非常简单的 Python 库,实现了朴素贝叶斯分类器。 示例代码: """
Suppose you have some texts of news and know their cate...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论