naive bayes

it‘s all about conditional probability and combined probability.

bg2011082502
P(A|B)=P(AB) / P(B)
=> P(A|B)=P(A)P(B|A) / P(B)
=> P(A|B)=P(A)P(B|A) / (P(A)P(B|A)+P(A’)P(B|A’))

joint probability
assumption : events are independent .
E1 = p(s|w1)*p(s|w2)*p(s)
E2 = (1-p(s|w1))*(1-p(s|w2))*(1-p(s))

P(S|w1,w2) = P(S)P(S|w1)P(S|w2)   /  (  P(S)P(S|w1)P(S|w2) +  P(~S)P(~S|w1)P(~S|w2) )

 

bayesian inference

后验概率 = 先验概率 x 调整因子

 

usage example

1.spam mail filter

 

reference:

http://www.ruanyifeng.com/blog/2011/08/bayesian_inference_part_one.html

http://www.paulgraham.com/spam.html