Solve them and check answers →Read the notes first
Aug 2023 (day not given)
A binary classification dataset contains only one feature and the data points given the label follow the Gaussian distributions whose means and variances are already estimated as $x\mid(y=0)\sim N(0,1)$ and $x\mid(y=1)\sim N(2,2)$. What will be the prediction for the point $x=1$? Assume that $\hat p$, an estimate for $P(y=1)$, is $0.5$.
Question Q16
Consider a probability distribution over $(X,y)$ where features are one-dimensional and $y\in\{+1,-1\}$. Let $X\mid(y=1)$ follow a uniform distribution over $[0,4]$ and $X\mid(y=-1)$ follow a uniform distribution over $[2,4]$.Let $x=2$ and let $\hat p$ be the estimate for $p=P(y=1)$. Find conditions on $\hat p$ such that the Bayes classifier predicts $1$ for this $x$. Consider that the tie-breaker is predicted in class $1$.
- $\hat p\le\frac14$
- $\hat p\ge\frac14$
- $\hat p\le\frac23$
- $\hat p\ge\frac23$
Question Q15
Consider a probability distribution over $(X,y)$ where features are one-dimensional and $y\in\{+1,-1\}$. Let $X\mid(y=1)$ follow a uniform distribution over $[0,4]$ and $X\mid(y=-1)$ follow a uniform distribution over $[2,4]$.If $p=P(y=1)$ is estimated to be $0.4$, what will be the prediction for the point $x=3$ using the Bayes classifier? Enter $1$ or $-1$.
Question Q17
Consider a probability distribution over $(X,y)$ where features are one-dimensional and $y\in\{+1,-1\}$. Let $X\mid(y=1)$ follow a uniform distribution over $[0,4]$ and $X\mid(y=-1)$ follow a uniform distribution over $[2,4]$.If $p=P(y=1)$ is estimated to be $0.5$ using MLE on a given training dataset, what will be the training error of the Bayes classifier for this problem?
Question Q19
A naive Bayes model is trained on the data matrix $X$ of shape $(d,n)$ and label vector $y$: $X=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&1&1&0\end{bmatrix}$, $y=[1,0,1,0]^T$. Assume $\hat p$ and $\hat p_j^{\,y_i}$ are estimates for $P(y=1)$ and $P(f_j=1\mid y=y_i)$, where $f_i$ is the $i^{\text{th}}$ feature. These parameters are estimated using MLE. Do not apply any smoothing.Calculate the value of $\hat p_2^{\,0}$.
Question Q20
A naive Bayes model is trained on the data matrix $X$ of shape $(d,n)$ and label vector $y$: $X=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&1&1&0\end{bmatrix}$, $y=[1,0,1,0]^T$. Assume $\hat p$ and $\hat p_j^{\,y_i}$ are estimates for $P(y=1)$ and $P(f_j=1\mid y=y_i)$, where $f_i$ is the $i^{\text{th}}$ feature. These parameters are estimated using MLE. Do not apply any smoothing.Calculate the value of $\hat p_2^{\,1}$.
Aug 2025 (03 Aug)
Question Q9
Which among the following are true?
- In generative model, we are interested in how the features are generated.
- In discriminative model, we are interested in how the features are generated.
- In discriminative model, we are interested in modelling $p(y\mid x)$ where $y$ is the label and $x$ is a feature.
- In generative model, we are interested in modelling $p(y\mid x)$, where $y$ is the label and $x$ is a feature.
- Gaussian Naive Bayes is a discriminative model.
Question Q15
Consider a 2-class Naive Bayes classifier with the first feature $f_1$ binary and the second feature $f_2$ Gaussian. Estimate of $P(Y=1)$: $\hat p=0.4$. Estimate of $P(f_1=1\mid y=0)$: $\hat p_1^{\,0}=0.4$. Estimate of $P(f_1=1\mid y=1)$: $\hat p_1^{\,1}=0.5$. $(f_2\mid y=0)\sim\text{Normal}(0,1)$ and $(f_2\mid y=1)\sim\text{Normal}(1,1)$.If a test point has label $0$, what will be the probability that the point is $x_{\text{test}}=[0\ \ 0]^T$? Enter the answer correct to two decimal places.
Question Q16
Consider a 2-class Naive Bayes classifier with the first feature $f_1$ binary and the second feature $f_2$ Gaussian. Estimate of $P(Y=1)$: $\hat p=0.4$. Estimate of $P(f_1=1\mid y=0)$: $\hat p_1^{\,0}=0.4$. Estimate of $P(f_1=1\mid y=1)$: $\hat p_1^{\,1}=0.5$. $(f_2\mid y=0)\sim\text{Normal}(0,1)$ and $(f_2\mid y=1)\sim\text{Normal}(1,1)$.For $x_{\text{test}}=[0\ \ 1.5]^T$ what output would the Naive Bayes model predict?
Apr 2026 (06 Apr)
Question Q13
You are provided with a training set of $5$ observations, each consisting of four binary features $X=\{X_1,X_2,X_3,X_4\}$ and a binary target label $Y\in\{0,1\}$.| Sample ID | $X_1$ | $X_2$ | $X_3$ | $X_4$ | $Y$ |
|---|---|---|---|---|---|
| 1 | 1 | 0 | 1 | 1 | 1 |
| 2 | 0 | 1 | 1 | 0 | 0 |
| 3 | 1 | 1 | 0 | 1 | 1 |
| 4 | 0 | 0 | 1 | 1 | 1 |
| 5 | 1 | 0 | 0 | 0 | 0 |
Using the Naive Bayes assumption and the data provided, calculate the joint probability $P(X,Y=1)$ for a new test instance $X=(1,0,1,1)$. Enter your answer correct to two decimal places.
Question Q14
You are provided with a training set of $5$ observations, each consisting of four binary features $X=\{X_1,X_2,X_3,X_4\}$ and a binary target label $Y\in\{0,1\}$.| Sample ID | $X_1$ | $X_2$ | $X_3$ | $X_4$ | $Y$ |
|---|---|---|---|---|---|
| 1 | 1 | 0 | 1 | 1 | 1 |
| 2 | 0 | 1 | 1 | 0 | 0 |
| 3 | 1 | 1 | 0 | 1 | 1 |
| 4 | 0 | 0 | 1 | 1 | 1 |
| 5 | 1 | 0 | 0 | 0 | 0 |
To address zero-probability estimates using Laplace smoothing, the dataset is augmented with synthetic observations. Specifically, add the following two samples to the original table: (1) one sample in which all features $(X_1,X_2,X_3,X_4)$ take the value $1$ and the class label is $Y=1$; (2) one sample in which all features take the value $1$ and the class label is $Y=0$. Based on this new augmented dataset of $7$ samples, calculate the updated conditional probability $P(X_2=1\mid Y=1)$.
Question Q15
You are provided with a training set of $5$ observations, each consisting of four binary features $X=\{X_1,X_2,X_3,X_4\}$ and a binary target label $Y\in\{0,1\}$.| Sample ID | $X_1$ | $X_2$ | $X_3$ | $X_4$ | $Y$ |
|---|---|---|---|---|---|
| 1 | 1 | 0 | 1 | 1 | 1 |
| 2 | 0 | 1 | 1 | 0 | 0 |
| 3 | 1 | 1 | 0 | 1 | 1 |
| 4 | 0 | 0 | 1 | 1 | 1 |
| 5 | 1 | 0 | 0 | 0 | 0 |
For the Naive Bayes model described in the main data with $n$ binary features and a binary class label, how many independent parameters are required to fully specify the model? Answer for the original dataset with $5$ training examples.
- $5$
- $8$
- $9$
- $10$
Aug 2026 (14 Aug)
Question Q11
A generative classifier models the joint distribution of the feature vector $X$ and the class label $Y$. For a particular email represented by the feature vector $x$, suppose $P(X=x,Y=\text{Spam})=0.015$ and $P(X=x,Y=\text{Not Spam})=0.035$. Compute the posterior probability $P(Y=\text{Spam}\mid X=x)$.
Question Q2
Suppose an email is represented by a binary feature vector $X=(x_1,x_2,\dots,x_d)\in\{0,1\}^d$. A generative classifier first chooses the class label $Y$ according to the prior distribution $P(Y)$. It then generates the feature vector $X$ conditioned on the chosen class. The classifier assumes that, given the class label, the features are conditionally independent. Which of the following expressions correctly represents $P(Y=\text{Spam}\mid X=x)$?
- $\dfrac{P(Y=\text{Spam})}{P(X=x)}$
- $\dfrac{\left(\prod_{i=1}^dP(x_i)\right)P(Y=\text{Spam})}{P(X=x)}$
- $\prod_{i=1}^dP(Y=\text{Spam}\mid x_i)$
- $\dfrac{\left(\prod_{i=1}^dP(x_i\mid Y=\text{Spam})\right)P(Y=\text{Spam})}{P(X=x)}$
Dec 2024 (01 Dec)
Question Q10
Suppose you want to use a Naive Bayes classifier to predict whether a student will pass or fail an exam based on two features: the number of hours they studied and whether they attended review sessions. Assume that the features are conditionally independent given the exam outcome and that the variances of the study hours distributions are equal for both pass and fail categories. How many parameters are required to classify a new student using this Naive Bayes classifier?
Question Q6
A binary classification dataset has $2000$ data points belonging to $\{0,1\}^2$. A Naive Bayes algorithm was run on the same dataset, resulting in the following estimates: $\hat p$, estimate for $P(y=1)$, is $0.4$; $\hat p_1^{\,0}$, estimate for $P(f_1=1\mid y=0)$, is $0.25$; $\hat p_2^{\,0}$, estimate for $P(f_2=1\mid y=0)$, is $0.35$; $\hat p_1^{\,1}$, estimate for $P(f_1=1\mid y=1)$, is $0.15$; $\hat p_2^{\,1}$, estimate for $P(f_2=1\mid y=1)$, is $0.05$.What is the estimated value of $P(f_2=0\mid y=1)$? Write your answer correct to two decimal places.
Question Q7
A binary classification dataset has $2000$ data points belonging to $\{0,1\}^2$. A Naive Bayes algorithm was run on the same dataset, resulting in the following estimates: $\hat p$, estimate for $P(y=1)$, is $0.4$; $\hat p_1^{\,0}$, estimate for $P(f_1=1\mid y=0)$, is $0.25$; $\hat p_2^{\,0}$, estimate for $P(f_2=1\mid y=0)$, is $0.35$; $\hat p_1^{\,1}$, estimate for $P(f_1=1\mid y=1)$, is $0.15$; $\hat p_2^{\,1}$, estimate for $P(f_2=1\mid y=1)$, is $0.05$.What will be the predicted label for the data point $[1,0]^T$?
Aug 2024 (04 Aug)
Question Q29
Consider a multi-class classification problem with $3$ classes and $4$ features, all of which are binary. A generative model is used to model the joint distribution of the features and labels.Find the total number of independent (free) parameters in the model if the class conditional independence assumption is not enforced.
Question Q30
Consider a multi-class classification problem with $3$ classes and $4$ features, all of which are binary. A generative model is used to model the joint distribution of the features and labels.Find the total number of independent (free) parameters in the model if the class conditional independence assumption is enforced.
Question Q25
Assume there is no smoothing. Consider the dataset for a binary classification problem with features in $\{0,1\}^3$ and labels in $\{0,1\}$: $X=\begin{bmatrix}1&0&1&1&0&1&0&0\\0&1&0&1&1&0&1&1\\1&1&0&1&0&0&1&0\end{bmatrix}$, $y=[1,1,1,1,0,0,0,0]^T$. (The bank notes that the matrix columns in the PDF text are slightly compressed: $8$ samples, $4$ with $y=1$ and $4$ with $y=0$.) A Naive Bayes classifier is trained. The parameters are $\hat p_i^{\,y}$, the probability of feature $i$ being $1$ in class $y$:| $i$ | $y=0$ | $y=1$ |
|---|---|---|
| 1 | $a$ | $b$ |
| 2 | $c$ | $d$ |
| 3 | $e$ | $f$ |
Find the value of $c+d$.
Question Q26
Assume there is no smoothing. Consider the dataset for a binary classification problem with features in $\{0,1\}^3$ and labels in $\{0,1\}$: $X=\begin{bmatrix}1&0&1&1&0&1&0&0\\0&1&0&1&1&0&1&1\\1&1&0&1&0&0&1&0\end{bmatrix}$, $y=[1,1,1,1,0,0,0,0]^T$. (The bank notes that the matrix columns in the PDF text are slightly compressed: $8$ samples, $4$ with $y=1$ and $4$ with $y=0$.) A Naive Bayes classifier is trained. The parameters are $\hat p_i^{\,y}$, the probability of feature $i$ being $1$ in class $y$:| $i$ | $y=0$ | $y=1$ |
|---|---|---|
| 1 | $a$ | $b$ |
| 2 | $c$ | $d$ |
| 3 | $e$ | $f$ |
Find the value of $a+c+e$.
Question Q27
Assume there is no smoothing. Consider the dataset for a binary classification problem with features in $\{0,1\}^3$ and labels in $\{0,1\}$: $X=\begin{bmatrix}1&0&1&1&0&1&0&0\\0&1&0&1&1&0&1&1\\1&1&0&1&0&0&1&0\end{bmatrix}$, $y=[1,1,1,1,0,0,0,0]^T$. (The bank notes that the matrix columns in the PDF text are slightly compressed: $8$ samples, $4$ with $y=1$ and $4$ with $y=0$.) A Naive Bayes classifier is trained. The parameters are $\hat p_i^{\,y}$, the probability of feature $i$ being $1$ in class $y$:| $i$ | $y=0$ | $y=1$ |
|---|---|---|
| 1 | $a$ | $b$ |
| 2 | $c$ | $d$ |
| 3 | $e$ | $f$ |
Find the predicted label for the test point $[0,1,0]^T$.
Mar 2024 (24 Mar)
Question Q15
Suppose you have a five-class classification problem where class label $y\in(0,1,2,3,4)$ and each training example $x_i$ has binary features $f_1,f_2,f_3\in(0,1)$. How many parameters do we need to know to classify an example using Naive Bayes classifier?
Question Q9
A naive Bayes model is trained on the data matrix $X$ of shape $(d,n)$ and label vector $y$: $X=\begin{bmatrix}1&0&0&0\\0&1&0&1\\0&1&1&0\end{bmatrix}$, $y=[1,0,1,1]^T$. Assume $\hat p$ and $\hat p_j^{\,y_i}$ are estimates for $P(y=1)$ and $P(f_j=1\mid y=y_i)$, where $f_i$ is the $i^{\text{th}}$ feature. These parameters are estimated using MLE.Calculate the value of $\hat p_2^{\,1}$.
Question Q10
A naive Bayes model is trained on the data matrix $X$ of shape $(d,n)$ and label vector $y$: $X=\begin{bmatrix}1&0&0&0\\0&1&0&1\\0&1&1&0\end{bmatrix}$, $y=[1,0,1,1]^T$. Assume $\hat p$ and $\hat p_j^{\,y_i}$ are estimates for $P(y=1)$ and $P(f_j=1\mid y=y_i)$, where $f_i$ is the $i^{\text{th}}$ feature. These parameters are estimated using MLE.Calculate the value of $\hat p_1^{\,1}$.
Dec 2023 (day not given)
Question Q12
Consider the problem of classifying an input text as positive sentiment or negative sentiment. For example, the text "I am happy" is positive and the text "I am a bit worried" is negative. The dictionary that is used to encode the text into a vector contains $12$ words. Suppose we prefer to use a generative learning algorithm that estimates the joint probability $P(x,y)$ where $x\in\{0,1\}^{12}$ and $y\in\{0,1\}$. Assume that the features $x_i$ in a sample are not independent given the label. How many parameters do we need to estimate from the given data? (Enter $-1$ if you think the given information is insufficient to find the answer.)
Question Q16
Consider the dataset with $6$ samples and labels; each sample has three binary features $f_1,f_2,f_3$.| sample | $f_1$ | $f_2$ | $f_3$ | $y$ |
|---|---|---|---|---|
| $x_1$ | 1 | 1 | 0 | 1 |
| $x_2$ | 0 | 1 | 0 | 1 |
| $x_3$ | 1 | 0 | 0 | 0 |
| $x_4$ | 0 | 0 | 1 | 0 |
| $x_5$ | 1 | 0 | 1 | 0 |
| $x_6$ | 1 | 1 | 1 | 1 |
What is the estimated probability that the test point belongs to class $0$ (that is, $p(y=0\mid x_{\text{test}})$)?
Question Q17
Consider the dataset with $6$ samples and labels; each sample has three binary features $f_1,f_2,f_3$.| sample | $f_1$ | $f_2$ | $f_3$ | $y$ |
|---|---|---|---|---|
| $x_1$ | 1 | 1 | 0 | 1 |
| $x_2$ | 0 | 1 | 0 | 1 |
| $x_3$ | 1 | 0 | 0 | 0 |
| $x_4$ | 0 | 0 | 1 | 0 |
| $x_5$ | 1 | 0 | 1 | 0 |
| $x_6$ | 1 | 1 | 1 | 1 |
What will be the predicted label according to the Naive Bayes decision rule?
Mar 2025 (16 Mar)
Question Q3
Consider a $k$-class classification problem with five binary features $f_1,f_2,f_3,f_4$ and $f_5$, where $k>2$. How many parameters need to be estimated to learn a Naive Bayes classifier?
- $5k$
- $6k-1$
- $(6k-1)^5$
- $3k-3$
Question Q5
What is the main purpose of using Laplace smoothing in Naïve Bayes?
- To prevent numerical errors when calculating the variance of Gaussian features.
- To ensure that unseen categorical feature values receive small but nonzero probabilities.
- To strengthen the model's predictions by increasing the weight of certain features.
- To balance the likelihood values of all features before computing posterior probabilities.
Question Q10
Consider a Naive Bayes problem with three features $f_1,f_2,f_3$ for a binary classification problem. We have a total of $6$ training samples:
For $x_{\text{test}}=[1,1,0]^T$ what output would the Naive Bayes model predict, assuming that no Laplacian smoothing has been done as part of the algorithm?
| Sample | $f_1$ | $f_2$ | $f_3$ | $y$ |
|---|---|---|---|---|
| $x_1$ | 1 | 0 | 1 | 0 |
| $x_2$ | 1 | 0 | 1 | 0 |
| $x_3$ | 0 | 0 | 1 | 0 |
| $x_4$ | 0 | 0 | 0 | 1 |
| $x_5$ | 1 | 0 | 1 | 1 |
| $x_6$ | 0 | 1 | 0 | 1 |
Jul 2022 (day not given)
Question Q5
In a binary classification problem, consider the following distribution of data-points from the training data on the unit-square. [Figure in the bank: four blue points at the corners of the unit square with counts: $10$ at $(0,0)$, $40$ at $(1,0)$, $30$ at $(0,1)$, $20$ at $(1,1)$; axes $x_1$ and $x_2$.] For instance, $20$ data-points have the feature vector $[1,1]^T$. The labels for these points is not important now. Which of the following Naive Bayes models would be the best choice for this dataset? Select the most appropriate option.
- Bernoulli NB
- Categorical NB
- Multinomial NB
- Gaussian NB
Question Q6
$x=[x_1,x_2,x_3]^T$ is a feature vector and $y$ represents the label in a binary classification problem. Which of the following equations represents the "naive" assumption used in the Naive Bayes algorithm?
- $P(x,y)=P(y)\cdot P(x\mid y)$
- $P(x)=P(x_1)\cdot P(x_2)\cdot P(x_3)$
- $P(y\mid x)=\dfrac{P(y)\cdot P(x\mid y)}{P(x)}$
- $P(x\mid y)=P(x_1\mid y)\cdot P(x_2\mid y)\cdot P(x_3\mid y)$
Question Q27
Consider a binary classification problem. The training-data has several features out of which we have access to only two binary features $(x_1,x_2)$. The labels are $1$ and $2$ for the two classes. The training dataset has the following distribution of points:| Feature | Number of points | True label |
|---|---|---|
| (0,0) | 30 | 1 |
| (0,0) | 10 | 2 |
| (0,1) | 10 | 1 |
| (0,1) | 40 | 2 |
| (1,0) | 30 | 1 |
| (1,0) | 10 | 2 |
| (1,1) | 10 | 1 |
| (1,1) | 50 | 2 |
What is the value of $w_{11}$?
Question Q28
Consider a binary classification problem. The training-data has several features out of which we have access to only two binary features $(x_1,x_2)$. The labels are $1$ and $2$ for the two classes. The training dataset has the following distribution of points:| Feature | Number of points | True label |
|---|---|---|
| (0,0) | 30 | 1 |
| (0,0) | 10 | 2 |
| (0,1) | 10 | 1 |
| (0,1) | 40 | 2 |
| (1,0) | 30 | 1 |
| (1,0) | 10 | 2 |
| (1,1) | 10 | 1 |
| (1,1) | 50 | 2 |
What is the value of $w_{12}$?
Question Q29
Consider a binary classification problem. The training-data has several features out of which we have access to only two binary features $(x_1,x_2)$. The labels are $1$ and $2$ for the two classes. The training dataset has the following distribution of points:| Feature | Number of points | True label |
|---|---|---|
| (0,0) | 30 | 1 |
| (0,0) | 10 | 2 |
| (0,1) | 10 | 1 |
| (0,1) | 40 | 2 |
| (1,0) | 30 | 1 |
| (1,0) | 10 | 2 |
| (1,1) | 10 | 1 |
| (1,1) | 50 | 2 |
What is the value of $w_{21}$?
Question Q30
Consider a binary classification problem. The training-data has several features out of which we have access to only two binary features $(x_1,x_2)$. The labels are $1$ and $2$ for the two classes. The training dataset has the following distribution of points:| Feature | Number of points | True label |
|---|---|---|
| (0,0) | 30 | 1 |
| (0,0) | 10 | 2 |
| (0,1) | 10 | 1 |
| (0,1) | 40 | 2 |
| (1,0) | 30 | 1 |
| (1,0) | 10 | 2 |
| (1,1) | 10 | 1 |
| (1,1) | 50 | 2 |
What is the value of $w_{22}$?