Naive Bayes classifier

The naive Bayes classifier is a probabilistic classification model that uses Bayes’ theorem to compute the probability of each class given the features and picks the most probable one. The adjective naive refers to a fundamental simplifying assumption: the features are treated as conditionally independent given the class. Thanks to it, the complex joint probability decomposes into a simple product of individual probabilities, which are estimated by plain frequency counting in the training data. The assumption is almost always violated in practice – words in a sentence are plainly not independent – yet the model works remarkably well, because for a correct decision it suffices that the ordering of the probabilities be right, not their absolute values. A necessary technical addition is Laplace smoothing, which prevents a single never-seen feature from zeroing out the whole product. Variants differ in the assumed distribution: multinomial for word counts, Bernoulli for binary occurrence, Gaussian for continuous quantities. Historically it was the standard spam filter, and it remains an excellent fast baseline for text classification, surpassed in accuracy only by models such as BERT.


Imagine deciding whether an e-mail is spam with a single rule: add up the suspiciousness of the individual words. “Prize” argues for spam, “invoice” against, “urgently” for. That the words actually influence one another – “prize” right after “your” means something different than in a sports report – you simply and knowingly ignore, because counting all the combinations would be impossible. Even so you decide correctly quite often, because you do not need the exact probability to decide; it is enough to know which way the scales tip.

Is this article useful to you and are you citing it? Copy the citation