Naive Bayes Classifier
Class Likelihoods
How x determines P(x|class)
At x=1.0, the spam curve gives density 0.228 vs ham's 0.038. The observation is closer to spam's mean (2), so P(x|spam) > P(x|ham). These likelihoods feed into Bayes' rule in the next step.
Step 1 of 6: Class Likelihoods
How x determines P(x|class)
At x=1.0, the spam curve gives density 0.228 vs ham's 0.038. The observation is closer to spam's mean (2), so P(x|spam) > P(x|ham). These likelihoods feed into Bayes' rule in the next step.
Step 2 of 6: Bayes' Rule
Prior × likelihood ÷ evidence = posterior
= 0.228 × 0.40 + 0.038 × 0.60
= 0.1138
With a 40% prior on spam and observing x=1.0, the posterior favours spam at 80.2%. Drag the x slider towards the spam mean (2) to increase P(x|spam), or towards the ham mean (-1) to increase P(x|ham).
Step 3 of 6: The Naive Assumption
Features are independent
High correlation violates the naive assumption significantly — yet NB often still works surprisingly well because it only needs the right class ranking, not calibrated probabilities.
Step 4 of 6: Combining Features
Multiplying independent likelihoods
P(x₁|ham)·P(x₂|ham) = 0.038 × 0.133 = 0.0050
= 0.0789 × 0.50 / (0.0395 + 0.0025)
= 0.940
Both features combined favour spam (94.0%). The naive assumption lets us simply multiply P(x₁|spam) × P(x₂|spam) instead of modelling joint distributions. Try moving x₂ towards ham's mean (-0.5) to see the features disagree.
Step 5 of 6: Decision Boundary
Where posteriors are equal
With equal priors, the decision boundary depends only on the likelihoods — it sits where P(A|x) = P(B|x).
Step 6 of 6: Spam or Ham?
Text classification example
The combined word likelihoods favour spam (99.5%). The strongest spam signal is "prize" with a spam/ham ratio of 25.0. Try lowering spam-indicative words or raising ham-indicative ones to flip the verdict.