Gaussian Naive Bayes for Continuous Features
What you'll learn: How to apply Naive Bayes to real-valued features by modeling them with normal (Gaussian) distributions.
The Challenge with Continuous Data
So far, you've seen Bayes' Theorem and the naive independence assumption. But what happens when your features aren't discrete categories (like "red" or "blue") but continuous numbers (like height, temperature, or salary)? You can't just count occurrences anymore.
The Gaussian Solution
Gaussian Naive Bayes solves this by assuming each continuous feature follows a normal (Gaussian) distribution within each class. For each class and each feature, you calculate two parameters:
- μ (mu): the mean value
- σ² (sigma squared): the variance
Think of it like this: if you're classifying emails as spam or not-spam based on word frequency (a continuous value), spam emails might have an average frequency of 5.2 mentions of "free" with some spread, while legitimate emails average 0.3 mentions with their own spread.
Computing Probabilities
When a new data point arrives, you plug its feature values into the Gaussian probability density function for each class:
P(feature | class) = (1 / √(2πσ²)) × exp(-(x - μ)² / (2σ²))
This gives you the likelihood of observing that feature value given the class. Combined with Bayes' Theorem and the naive assumption (multiply all feature probabilities together), you get the posterior probability for each class.
Why It Works
The Gaussian distribution is a natural fit for many real-world continuous measurements. By estimating just the mean and variance from your training data, you can evaluate the probability of any new value.
Key Takeaway: Gaussian Naive Bayes models continuous features using normal distributions (mean and variance per class), then computes class probabilities by evaluating how likely each feature value is under those distributions.