1. University MCA (AI/ML) Semester 2
  2. CAB212
  3. Unit 3

CAB212 · Unit 3: Classification

Naive Bayes classifier

8 practice questions

Key points

  • Posterior proportional to likelihood x prior
  • Assumes conditional independence
  • Laplace smoothing avoids zero probabilities
  • Good, fast text baseline

Naive Bayes applies Bayes' theorem: P(C|x) = P(x|C) P(C) / P(x), and assumes features are conditionally independent given the class, so P(x|C) = product of P(x_i|C). It predicts the class with the largest posterior; P(x) can be ignored when comparing classes.

Variants: Gaussian (continuous features), Multinomial (word counts), Bernoulli (binary features).

Laplace smoothing adds 1 to counts so an unseen feature value does not give probability zero: P = (count + 1) / (total + number of categories).

Worked example: P(spam)=0.4, P(word|spam)=0.5, P(word|ham)=0.1. Posterior spam = 0.4*0.5 / (0.4*0.5 + 0.6*0.1) = 0.2/0.26 = 0.769.

Strengths: fast, works with little data, good for text. Weakness: independence assumption is rarely true, so probabilities are poorly calibrated even when classification is good.

Exam pitfall: "naive" refers to the independence assumption, not to poor accuracy.

Try two questions

Question 1 · Tier 3, Apply

Which Naive Bayes variant suits continuous features assumed normal within each class?

  1. Complement Naive Bayes only
  2. Gaussian Naive Bayes
  3. Multinomial Naive Bayes
  4. Bernoulli Naive Bayes
Show the answer

B. Gaussian NB fits a normal per feature and class.

Question 2 · Tier 3, Apply

Which Naive Bayes variant suits word-count features?

  1. Gaussian, for continuous measurements
  2. K-means with Euclidean centroids
  3. Linear, with a weight vector
  4. Multinomial
Show the answer

D. Multinomial models count data.