Naive Bayes

GATE DA previous year questions · 2 questions

GATE DA 2025 | Question 35

NAT · 1 mark

The naive Bayes classifier is used to solve a two-class classification problem with class-labels \(y_1, y_2\). Suppose the prior probabilities are \(P(y_1) = \frac{1}{3}\) and \(P(y_2) = \frac{2}{3}\). Assuming a discrete feature space with

\[P(x|y_1) = \frac{3}{4} \quad \text{and} \quad P(x|y_2) = \frac{1}{4}\]

for a specific feature vector \(x\). The probability of misclassifying \(x\) is __________
(Round off to two decimal places)

Explanation

Answer: 0.39 to 0.41

Naive Bayes compares prior times likelihood for the two classes:

  • \(P(y_1)P(x|y_1) = \frac{1}{3} \cdot \frac{3}{4} = \frac{1}{4}\)
  • \(P(y_2)P(x|y_2) = \frac{2}{3} \cdot \frac{1}{4} = \frac{1}{6}\)

So \(P(x) = \frac{1}{4} + \frac{1}{6} = \frac{5}{12}\), giving posteriors \(P(y_1|x) = \frac{3}{5}\) and \(P(y_2|x) = \frac{2}{5}\). The classifier picks the larger posterior, \(y_1\), and it is wrong exactly when \(x\) really belongs to \(y_2\), which has probability \(P(y_2|x) = 0.40\). The larger prior of \(y_2\) is outweighed by the much higher likelihood under \(y_1\).

Answer: 0.40

GATE DA 2024 | Question 20

MCQ · 1 mark · −0.33

Given a dataset with \(K\) binary-valued attributes (where \(K > 2\)) for a two-class classification task, the number of parameters to be estimated for learning a naïve Bayes classifier is

Options for GATE DA 2024 | Question 20

Explanation

Answer: (B)

Naïve Bayes assumes that the attributes are conditionally independent given the class, so it needs only these parameters:

  • the class prior \(P(y = 1)\): one parameter, because \(P(y = 0) = 1 - P(y = 1)\);
  • for each of the 2 classes and each of the \(K\) attributes, \(P(x_{k} = 1 \mid y)\): \(2K\) parameters, because \(P(x_{k} = 0 \mid y)\) follows from it.

The total is \(2K + 1\). Counts that grow like \(2^{K}\) (A and C) are what a model of the full joint distribution of the attributes within each class would need, which is exactly what the independence assumption avoids.

Answer: B