Naive Bayes Classifier
The Problem
The Naive Bayes classifier is a famous classification technique that takes a probabilistic approach.
Consider a dataset where, for any input feature , the output is either or . This is binary classification, where we have two categories. Naive Bayes can be extended to multiclass classification, but we'll start with the binary case.
For example, suppose we are given a person's glucose level, and each person is labeled as normal or high risk. Risk increases with glucose level. We'll treat normal as and high risk as .
Consider any input and output as coming from two random variables, and . For new data, we need to calculate the probability of the output given the input:
For simplicity, we'll write this as .
We can't read this directly from the training data, but we can calculate two related probabilities:
- , the probability of the input given the output class
- , the probability of the output class
For any output class, we know the inputs that belong to it, so we can calculate both of these from the dataset. What we need is a way to get from them to .
Bayes' Theorem
Think of a Venn diagram with two overlapping circles, and . The overlap is .
- asks: given that we are in , what is the probability of ?
- asks: given that we are in , what is the probability of ?