Multinomial naive bayes classifier

本文介绍了一个基于多项式朴素贝叶斯分类器的短信垃圾信息过滤系统实现。通过计算每个单词在垃圾短信(spam)和非垃圾短信(ham)中出现的概率,并采用加一平滑处理避免概率为零的情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

LAB 4

Multinomial naive bayes classifier to predict spam SMS.WE implement a unigram model here

  1. we need to caculate following

which is the probility of class_i occur in all document , in this case we have two class ,one is spam and another is ham
in this case

  1. after that,we apply following equition, this is the likelihood of that word given a class ,

w represent word , c represent class

count(w,c) is the total number of that word occur in that class

count ( c ) is the total number of word in that class

we also use add-1 smoothing in this case , the purpose is that we aviod the 0 appear in the probility in the every single word by add 1 in the Numerator and add V which is the total number of set(all wrods) to the denominator,althongh the word not occur in the vacabulary ,the probility will not assign 0

  1. Caculate the Conditional Probilities

By implement the equition in 2 , calculate the P(word|class) of all the word in the sms both in spam and ham ,after that we are able to caculate the likelihood of P(class ham|sms) and P(class spam|sms)

which is

i : every word in the sms

and using same equition in spam ,after that caculating the ratio and all good to go (:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值