Vocabulary size K=5: {buy, free, meeting, project, lunch}. In the spam class we saw N=8 words total, with counts: buy=4, free=3, meeting=1, project=0, lunch=0.
Raw MLE for "project":
PML(project∣spam)=80=0→ kills the product
Why this step? Shows the failure: any email containing "project" would get spam-score 0 regardless of other words.
Add-one (α=1):
P(project∣spam)=8+1⋅50+1=131≈0.077
Why this step? Denominator is N+αK=8+5. Now the impossible becomes merely unlikely.
Check "buy":
P(buy∣spam)=8+54+1=135≈0.385
Why this step? Smoothing shrinks confident estimates slightly toward uniform (1/5=0.2), which is desirable regularization.
Sum check: 135+4+2+1+1=1313=1 ✓
Why this step? Confirms it's a valid distribution — the whole point of using αK.
Why this step? As α→∞, every estimate →K1 (max smoothing, ignores data). As α→0, we recover raw MLE. So α is a bias–variance knob, tuned by cross-validation.
Suppose a test email contains "hello", which is not in the vocabulary for either class. Handling: either drop unknown tokens, or reserve an <UNK> slot so K counts it. If included with count 0:
P(hello∣spam)=Nspam+(K+1)0+1
Why this step? Consistency: you must use the sameK (including the UNK slot) in both numerator normalization and every class, otherwise probabilities across classes are on different scales.
Recall Feynman: explain to a 12-year-old
Imagine you're guessing which cereal box a toy comes in. You opened 8 boxes, saw some toys but never saw a robot. Does that mean a robot is impossible? No! You just haven't opened enough boxes. So before you start, you pretend you already found one of every toy. Now nothing is "impossible," just rare. That's Laplace smoothing — adding one imaginary sighting of everything so a surprise doesn't break your whole guess.
Before reading further, predict: if I double the vocabulary K but keep counts fixed, does a zero-count word's smoothed probability go up or down?
→ Down, because denominator N+αK grows while numerator α stays — more possible outcomes means each unseen one is individually rarer. (Verified in the VERIFY block.)
Dekho, Naive Bayes ka simple funda hai: har class ke liye hum saare feature probabilities ko multiply karte hain. Ab problem yeh hai — agar training data mein koi word kisi class ke saath ek baar bhi nahi dikha, to uski probability seedha 0 ban jaati hai. Aur 0 ko kisi bhi cheez se multiply karo, poora answer 0 ho jaata hai. Matlab ek anjaan word puri prediction ko barbaad kar deta hai. Yeh overconfident behaviour hai — "maine nahi dekha, iska matlab impossible hai" — jo galat hai.
Laplace smoothing isko fix karta hai bahut hi cute tareeke se: har outcome ko pehle se hi thoda count de do, jaise humne har cheez ek baar (ya α baar) dekh li ho. Formula banta hai N+αKcount+α. Yahan K = total possible values (text mein vocabulary size). Neeche αK isliye add karte hain taaki saari probabilities milke exactly 1 banein — warna distribution valid hi nahi rahega.
Deep baat yeh hai ki yeh koi jugaad nahi hai — yeh actually ek Dirichlet prior ke saath Bayesian estimate ka posterior mean hai. α ek knob hai: chhota α = data pe zyada bharosa (kam smoothing), bada α = sab kuch uniform (1/K) ki taraf khinch jaata hai (zyada smoothing). Isko cross-validation se tune karte ho. Bas yaad rakhna: "+α upar, +αK neeche" — zero kabhi nahi aayega, aur sab kuch sum-to-one rahega. Simple, powerful, exam-favourite.
Test yourself — SVM, Naive Bayes & Probabilistic Models