Back to Classic ML Mind Map
中文·English
📊 Classic MLID: naive-bayes

Naive Bayes

朴素贝叶斯
🎯Core Definition
Naive Bayes is a generative classifier built on Bayes' theorem; its core assumption is that features are conditionally independent given the class CC. By Bayes' theorem
📌Overview
P(Cx)P(C)iP(xiC),P(C \mid x) \propto P(C)\prod_{i} P(x_i \mid C),
📌Overview
the prior P(C)P(C) times the feature-likelihood product yields the posterior, and the class with maximum posterior is predicted — the normalizer P(x)P(x) is the same for all classes and cancels under argmax. The parameterization defines three variants: Multinomial NB (count features, multinomial distribution, for word counts in text), Gaussian NB (continuous features fit as P(xiC)=N(xi;μC,i,σC,i2)P(x_i \mid C) = \mathcal{N}(x_i; \mu_{C,i}, \sigma_{C,i}^2)), and Bernoulli NB (binary 0/1 features, Bernoulli distribution). If a feature-class pair never appears in training, the posterior product collapses to zero, hence Laplace smoothing
📌Overview
P^(xiy)=Ny,xi+αNy+αV,\hat P(x_i \mid y) = \frac{N_{y,x_i} + \alpha}{N_y + \alpha |V|},
📌Overview
with NyN_y the number of class-yy samples, Ny,xiN_{y,x_i} the count of feature xix_i in class yy, V|V| the vocabulary size, and α=1\alpha = 1 giving add-one smoothing.
💡Use Cases
text classification (spam, sentiment), fast baselines on high-dimensional sparse features, online incremental learning; interviews often ask to derive the conditional-independence posterior and compare NB with logistic regression.
Key Problems Solved
a generative view over high-dimensional discrete features with parameters growing linearly, no iterative training, and streaming updates; the cost is the strong conditional-independence assumption — correlated features bias probability estimates, though classification boundaries usually remain usable and NB stays robust to noisy features.
🎯5 High-Frequency Exam Points
1
Write the NB decision rule P(Cx)P(C)iP(xiC)P(C \mid x) \propto P(C)\prod_i P(x_i \mid C); what is the “naive” assumption and why can the denominator P(x)P(x) be dropped?
2
Why is Laplace smoothing needed? Write P^=Ny,xi+αNy+αV\hat P = \frac{N_{y,x_i}+\alpha}{N_y+\alpha|V|} and explain how zero probabilities are avoided.
3
What feature types are Multinomial, Gaussian, and Bernoulli NB each suited for?
4
Is NB generative or discriminative? How does it compare with logistic regression under limited data and strongly correlated features?
5
What happens when the conditional-independence assumption is violated, and why does NB still often deliver usable decisions in practice?
📖 In-depth Guide:📄 probabilistic-models
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Naive Bayes"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardPCA & SVDNext CardHMM Forward Algorithm (Evaluation)

🔗 More Classic ML Knowledge Cards

AdaBoost DerivationBagging & Random ForestBaum-Welch (HMM EM)GBDT Negative Gradient