Home Knowledge Base Naive Bayes

Naive Bayes is a family of fast, probabilistic classifiers based on Bayes' theorem that assume all features are conditionally independent given the class label — despite this "naive" assumption being almost never true in practice (words in an email are correlated, pixel values in an image are correlated), Naive Bayes works surprisingly well for text classification, spam filtering, and sentiment analysis, serving as the gold-standard baseline that more complex models must beat to justify their complexity.

What Is Naive Bayes?

Naive Bayes Variants

VariantFeature TypeUse CaseP(featureclass) Distribution
Multinomial NBWord counts / frequenciesText classification, spam filteringMultinomial distribution
Bernoulli NBBinary (present/absent)Short text, binary featuresBernoulli distribution
Gaussian NBContinuous (real-valued)General classification, sensor dataGaussian (normal) distribution
Complement NBWord counts (imbalanced)Imbalanced text classificationComplement of each class

Spam Classification Example

StepProcessCalculation
1. PriorP(Spam) from training data30% of emails are spam → P(Spam) = 0.3
2. LikelihoodP("free"Spam) from word frequencies"free" appears in 80% of spam → 0.8
3. LikelihoodP("meeting"Spam)"meeting" appears in 5% of spam → 0.05
4. PosteriorP(Spam"free", "meeting") ∝ 0.3 × 0.8 × 0.05= 0.012
5. CompareP(Ham"free", "meeting") ∝ 0.7 × 0.1 × 0.6= 0.042
6. DecisionHam wins (0.042 > 0.012)Classify as Ham

Strengths and Weaknesses

StrengthWeakness
Extremely fast training (single pass through data)Independence assumption is always violated
Works well with small datasetsCan't capture feature interactions
Handles high-dimensional data (10,000+ features)Probability estimates are often poorly calibrated
Excellent baseline for text classificationContinuous features require distribution assumption
Scales linearly with data sizeOutperformed by ensemble methods on tabular data

When to Use Naive Bayes

Naive Bayes is the "unreasonably effective" baseline classifier — proving that a mathematically simple model with a provably wrong assumption can outperform complex algorithms on text classification tasks, and serving as the benchmark that every sophisticated model must justify its additional complexity against.

naive bayesprobabilisticsimple

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.