A document is x=(x1,…,x∣V∣) where xt = count of word t, and n=∑txt is the length. Rolling a die n times with face-probabilities pt∣c gives the multinomial distribution:
P(x∣c)=∏txt!n!∏tpt∣cxt
Why this form?∏tpt∣cxt is the probability of one specific ordering of the rolls; ∏txt!n! counts how many orderings give the same counts. The factorial part is the same for every class, so it cancels in classification and we usually drop it.
We take logs (products underflow, sums are stable):
logP(c∣x)∝logP(c)+∑txtlogpt∣c
HOW we derive the MLE (why counts/total?): maximize ∑tNtclogpt∣c subject to ∑tpt∣c=1. Lagrangian L=∑tNtclogpt−λ(∑tpt−1). Setting ∂L/∂pt=Ntc/pt−λ=0 gives pt=Ntc/λ; the constraint forces λ=Nc, so pt∣c=Ntc/Nc. Smoothing just perturbs this.
Ham ∝21⋅41⋅21⋅(1−43)=21⋅41⋅21⋅41=641=0.0156
Why this step? Notice the extra (1−pmeeting) factor — Bernoulli rewards the absence of "meeting" (a hammy word). Multinomial ignored it entirely. → SPAM (even more confidently).
Recall Feynman: explain to a 12-year-old
Imagine sorting letters into "junk" and "real" piles.
Multinomial is like counting how many times each word shows up. The word "FREE!!!" appearing 5 times screams junk louder than appearing once.
Bernoulli just ticks a checklist: "Does the word 'free' show up? Yes/No." It doesn't care if it's 1 or 5 times — and it also notices when an expected friendly word like "meeting" is missing, which is a clue too.
Both then say: "Which pile makes this exact set of words most likely?" and pick that pile.
Given the class, all features are conditionally independent, so P(x∣c)=∏iP(xi∣c).
In Multinomial NB, what does each feature xt represent?
The count (frequency) of word t in the document.
In Bernoulli NB, what does each feature xt represent?
A binary indicator: whether word t is present (1) or absent (0).
Write the Multinomial NB parameter estimate with Laplace smoothing.
pt∣c=Nc+α∣V∣Ntc+α, where Ntc is total count of word t in class c.
Write the Bernoulli NB parameter estimate.
pt∣c=Dc+2αDtc+α, where Dtc is number of docs of class c containing word t.
Why is the denominator Dc+2α in Bernoulli but Nc+α∣V∣ in Multinomial?
Bernoulli word has 2 outcomes (present/absent) → 2α; Multinomial has ∣V∣ possible faces → α∣V∣.
Why does Multinomial ignore absent words but Bernoulli doesn't?
In Multinomial, pxt with xt=0 gives 1 (no contribution). In Bernoulli, absent words contribute the factor (1−pt∣c), explicitly penalizing/rewarding absence.
Why do we take logarithms of the Naive Bayes score?
Products of many small probabilities underflow numerically; logs turn products into stable sums.
Why is smoothing (α>0) necessary?
A single zero probability makes the whole product 0 (log0=−∞), so unseen words would veto a class. Smoothing keeps estimates finite.
Derive the MLE pt∣c=Ntc/Nc — what optimization gives it?
Maximize ∑tNtclogpt subject to ∑tpt=1 (Lagrange); yields pt=Ntc/Nc.
When should you prefer Multinomial over Bernoulli?
When word frequency carries signal and documents vary in length (typical for longer text / TF features); Bernoulli suits short texts where mere presence matters.
Dekho, dono Naive Bayes text classify karne ke liye same Bayes theorem use karte hain — bas ye difference hai ki word ko kaise dekhte hain. Multinomial NB word ki ginti (count/frequency) dekhta hai: agar "free" 5 baar aaya to signal zyada strong. Isse socho ek loaded dice ki tarah jiske har face pe ek word hai, aur document banane ke liye tum n baar roll karte ho. Isliye formula mein pt∣c=(Ntc+1)/(Nc+∣V∣) aata hai — total count divided by total words, plus Laplace smoothing.
Bernoulli NB sirf presence dekhta hai: word aaya ya nahi (1 ya 0). Har word ke liye ek coin flip. Ye ek chhoti par important baat karta hai — jab koi word absent hai to bhi wo score ko affect karta hai, kyunki formula mein (1−pt) factor lagta hai. Matlab agar "meeting" (ham-type word) missing hai to spam ka score badh jata hai. Multinomial isko ignore kar deta (p0=1).
Smoothing kyun? Agar koi word training mein kabhi nahi dikha, uski probability 0 ho jaati, aur ek bhi 0 poore product ko 0 bana deta (log0=−∞). Isliye α (usually 1) add karte hain — jaise har word ko thoda extra baar dekh liya ho. Multinomial mein denominator mein α∣V∣ add hota (kyunki ∣V∣ faces), Bernoulli mein 2α (kyunki sirf 2 outcomes: present/absent). Ye mat mix karna, warna probabilities galat ho jaati.
Rule of thumb: lambe documents / frequency matter kare to Multinomial, chhote text jahan sirf word ka hona-na-hona matter kare to Bernoulli. Yaad rakho — "Multi = Many (counts), Bern = Binary".
Test yourself — SVM, Naive Bayes & Probabilistic Models