2.4.7 · HinglishSVM, Naive Bayes & Probabilistic Models

Naive Bayes assumption

1,480 words7 min readRead in English

2.4.7 · AI-ML › SVM, Naive Bayes & Probabilistic Models


Assumption ki zaroorat KYUN hai?

Hum classify karna chahte hain: ek feature vector diya ho, toh woh class chunein jo sabse zyada probable ho.

Masla hai likelihood .


Chain rule — naive hone se pehle

ke baar-baar istemal se:

Ye exact hai lekin useless — baad ke terms abhi bhi sab pehle wali features par depend karte hain. Ab hum woh leap lete hain.

Har ek simple 1-D distribution hai — total parameters se ghatke lagbhag ho jaate hain. Yahi fayda hai.


Full classifier KAISE banta hai

Bayes' rule ko factorization ke saath combine karo:

Figure — Naive Bayes assumption

Worked Example 1 — Spam filter (Bernoulli/multinomial words)

Vocabulary features. , . Word likelihoods:

word
"free" 0.7 0.1
"win" 0.5 0.05

Message mein dono "free" aur "win" hain. Har class ko score karo:

  • Spam: Ye step kyun? Prior independent word likelihoods ki product (naive assumption).
  • Ham:

predict karo spam. Normalize karke: . Normalize kyun? Raw scores ko probability mein badalne ke liye unhe unke sum se divide karo.


Worked Example 2 — Gaussian Naive Bayes (continuous features)

Feature = height, do classes. Continuous ke liye hum table ki jagah Gaussian likelihood use karte hain:

Maano class A: ; class B: ; equal priors. Naya point .

Logs kyun? Numerical stability milti hai aur sums compare kar sakte hain. Class B ki chhoti variance + apne mean ke zyada paas hona yahan jeetta hai → predict karo B. (Narrow Gaussian apne mean ke paas hone ko reward karta hai.)


Galtiyon ko steel-man karna


Recall Feynman: ek 12-saal ke bachche ko samjhao

Socho fruit ko "apple" ya "orange" mein sort karna. Jab main tumhe bata deta hoon ki ye orange hai, tum uska rang aur uski bumpy skin alag-alag guess kar sakte ho — dono ko ek-dusre se consult nahi karna — orange hona already explain kar deta hai ki dono saath kyun hain. Naive Bayes pretend karta hai ki har clue aisa hi hai: jab tum answer-box jaante ho, har clue apni baat khud karta hai. Phir tum bas multiply karte ho ki har clue har box mein kitna fit baithta hai aur sabse bada choose karte ho.


Flashcards

Naive Bayes assumption kya hai?
Class label diya ho, toh saari features conditionally independent hain: .
Assumption likelihood ko kaise simplify karti hai?
Ye joint ko product mein badal deti hai.
Naive Bayes decision rule batao.
.
ko argmax se kyun drop kar sakte hain?
Ye classes mein constant hai, isliye ye decide nahi karta ki kaun si class maximal hai.
Naive Bayes mein logarithms kyun lete hain?
Kai chhoti probabilities multiply karne se numerical underflow avoid karne ke liye; log monotonic hai isliye argmax nahi badlta.
Conditional aur marginal independence mein kya fark hai?
Conditional independence diye jaane par hold karta hai; features marginally (overall) phir bhi dependent ho sakte hain.
Agar kisi feature ki zero conditional probability ho toh kya hoga?
Poori product zero ho jaati hai, us class ko khatam kar deti hai chahe doosre evidence kuch bhi kahein.
Zero-probability features ko kya fix karta hai?
Laplace/add-one smoothing: .
Galat assumption ke bawajood Naive Bayes kaam kyun karta hai?
Classification ko sirf sahi argmax (ranking) chahiye, calibrated probabilities nahi.
Continuous ke liye Gaussian NB likelihood kya hai?
.

Connections

Concept Map

via

needs

expanded exactly by

hopeless

motivates

conditional independence given y

collapses via F into

params drop to

combined with G gives

drop constant P of x

take logs to avoid underflow

applied in

Classify x pick best y

Bayes rule

Likelihood P of x given y

Chain rule

k^n params per class

Naive Bayes assumption

Product of 1-D P xi given y

about n times k

Posterior P of y given x

argmax rule

Sum of log probs

Spam filter example