Classify emails into ham and spam using Naive Bayes Classifier
We’ll build a simple email classifier using naive Bayes theorem. Algorithm implemented in PHP can be found here- https://github.com/varunon9/naive-bayes-classifier A little bit introduction- From wikipedia : P(A | B) = P(B | A) * P(A) / P(B) where A and B are events and P(B) != 0 P(A | B) is a conditional probability: the likelihood of event A occurring given that B is true. P(B | A) is also a conditional probability: the likelihood of event B occurring given that A is true. P(A) and P(B) are the probabilities of observing A and B independently of each other, this is known as the marginal probability. Now lets assume that we have few documents which are already classified as spam or ham ( training set ). So the problem that “ is this email ham or spam ” can also be stated as- What is the probability that latest email is ham or spam given that it contains following document? (Here document is some text ...