**1. Set Up the Log-Likelihood Function:**
- We are given \( n \) independent data points \( (x_i, y_i) \) where \( x_i \in \mathbb{R}^+ \), \( w > 0 \), and:
\[ y_i \mid x_i \sim \mathcal{N}(\log(w x_i), 1) \]
- Using logarithm properties, \( \log(w x_i) = \log(w) + \log(x_i) \). Let \( \theta = \log(w) \).
- The conditional probability density for each observation is:
\[ p(y_i \mid x_i; w) = \frac{1}{\sqrt{2\pi}} \exp\left( -\frac{1}{2} (y_i - \log(w) - \log(x_i))^2 \right) \]
**2. Maximize the Log-Likelihood with Respect to \( w \):**
- The log-likelihood function \( \ell(w) \) over all \( n \) points is:
\[ \ell(w) = -\frac{n}{2}\log(2\pi) - \frac{1}{2}\sum_{i=1}^n (y_i - \log(x_i) - \log(w))^2 \]
- Differentiating \( \ell(w) \) with respect to \( w \) and setting the derivative to zero:
\[ \frac{\partial \ell(w)}{\partial w} = \frac{1}{w}\sum_{i=1}^n (y_i - \log(x_i) - \log(w)) = 0 \]
- Since \( w > 0 \), we solve for \( \log(\hat{w}_{MLE}) \):
\[ n \log(\hat{w}_{MLE}) = \sum_{i=1}^n (y_i - \log(x_i)) \implies \log(\hat{w}_{MLE}) = \frac{1}{n}\sum_{i=1}^n (y_i - \log(x_i)) \]
- Taking the exponential on both sides yields:
\[ \hat{w}_{MLE} = \exp\left( \frac{1}{n}\sum_{i=1}^n (y_i - \log(x_i)) \right) \]
**Answer: \( \hat{w}_{MLE} = \exp\left(\frac{1}{n}\sum_{i=1}^n (y_i - \log(x_i))\right) \) (Option A).**
A: **Correct:** Setting the derivative of the Gaussian log-likelihood with mean \( \log(w) + \log(x_i) \) to zero gives \( \log(\hat{w}_{MLE}) = \frac{1}{n}\sum_{i=1}^n (y_i - \log(x_i)) \), so \( \hat{w}_{MLE} = \exp\left(\frac{1}{n}\sum_{i=1}^n (y_i - \log(x_i))\right) \).
B: **Incorrect:** The derivative of \( \log(w x_i) = \log(w) + \log(x_i) \) with respect to \( \log(w) \) is \( 1 \), so there is no extra factor of \( x_i \) multiplying \( y_i \) or \( \log(x_i) \).
C: **Incorrect:** \( \frac{1}{n}\sum_{i=1}^n (y_i - \log(x_i)) \) is the estimate for \( \log(w) \), so we must exponentiate it to obtain \( \hat{w}_{MLE} \).
D: **Incorrect:** \( y_i \) is not multiplied by \( x_i \) inside the sum.
**Setting 3**, because it has the lowest training error, indicating the best fit to the
training data.
6406534435320.
**Setting 2**, because it has the lowest validation error and a relatively low
training error, indicating a good generalization.
6406534435321.
**Setting 1**, because it has the highest number of iterations and therefore likely
to be more stable.
6406534435322.
**Setting 4**, because it uses the highest learning rate and converges the fastest.
Published solution
**1. Compare Training and Validation Errors Across Hyperparameter Settings:**
- **Setting 1:** Training Error = \( 150 \), Validation Error = \( 160 \).
- **Setting 2:** Training Error = \( 145 \), Validation Error = \( 150 \) (lowest validation error).
- **Setting 3:** Training Error = \( 140 \), Validation Error = \( 190 \) (low training error but high validation error, indicating overfitting).
- **Setting 4:** Training Error = \( 170 \), Validation Error = \( 180 \).
**2. Select the Best Hyperparameter Setting:**
- Hyperparameters are always chosen based on **validation error** because validation performance measures how well the model generalizes to unseen data.
- **Setting 2** achieves the lowest validation error (\( 150 \)) while maintaining a low training error (\( 145 \)), demonstrating the best generalization.
**Answer: Setting 2, because it has the lowest validation error and a relatively low training error, indicating a good generalization.**
A: **Incorrect:** Setting 3 has the lowest training error (140) but the highest validation error (190), which indicates overfitting rather than good generalization.
B: **Correct:** Setting 2 achieves the lowest validation error (150) along with a low training error (145), indicating the best generalization on unseen data.
C: **Incorrect:** More iterations alone do not guarantee better generalization; Setting 1 has higher training and validation errors than Setting 2.
D: **Incorrect:** Setting 4 has high training (170) and validation (180) errors due to an overly large learning rate.
**1. Bias-Variance Trade-off Between \( \hat{w}_{MLE} \) and \( \hat{w}_{MAP} \):**
- The Mean Squared Error (MSE) of an estimator \( \hat{w} \) is the sum of its squared bias and its variance:
\[ \text{MSE}(\hat{w}) = \mathbb{E}\left[\|\hat{w} - w\|^2\right] = \|\text{Bias}(\hat{w})\|^2 + \text{Var}(\hat{w}) \]
- While the ordinary least squares / MLE estimator \( \hat{w}_{MLE} \) is **unbiased** (\( \text{Bias}(\hat{w}_{MLE}) = 0 \)), it can have high variance (especially when features are correlated or sample size is small).
- The MAP / Ridge estimator \( \hat{w}_{MAP} = (X X^T + \lambda I)^{-1} X y \) introduces a small bias for \( \lambda > 0 \), but reduces variance significantly.
- By the existence theorem for Ridge regression, there always exists some regularization parameter \( \lambda > 0 \) for which the reduction in variance outweighs the squared bias, yielding \( \text{MSE}(\hat{w}_{MAP}) < \text{MSE}(\hat{w}_{MLE}) \).
**Answer: The estimator \( \hat{w}_{MAP} \) can achieve lower MSE than \( \hat{w}_{MLE} \) for some \( \lambda > 0 \), where \( \lambda \in \mathbb{R} \) (Option C).**
A: **Incorrect:** Being unbiased only guarantees zero bias, not minimum MSE; a slightly biased estimator with much lower variance can have a smaller total MSE.
B: **Incorrect:** \( \hat{w}_{MAP} \) does not *always* beat \( \hat{w}_{MLE} \) for every choice of \( \lambda \); if \( \lambda \) is too large, the squared bias dominates and increases MSE.
C: **Correct:** By trading a small amount of bias for a larger reduction in variance, \( \hat{w}_{MAP} \) (Ridge regression) can achieve a lower MSE than \( \hat{w}_{MLE} \) for an appropriate \( \lambda > 0 \).
D: **Incorrect:** When the sample size is small, \( \hat{w}_{MLE} \) has much higher variance than \( \hat{w}_{MAP} \), so their MSEs are not equal.
**1. Analyze the Effect of Duplicating Points and Adding Exact-Fit Points:**
- Let \( w^* = \arg\min_{w \in \mathbb{R}^d} \|X^T w - y\|_2^2 = \arg\min_{w} \sum_{i=1}^n (x_i^T w - y_i)^2 \).
- When we duplicate all \( n \) points in \( D \), the sum of squared errors over the duplicated dataset is simply \( 2 \sum_{i=1}^n (x_i^T w - y_i)^2 \).
- Next, we add 10 new points \( (\tilde{x}_j, \tilde{y}_j) \) that lie **exactly** on the hyperplane \( \tilde{y}_j = \tilde{x}_j^T w^* \).
**2. Check the Minimizer of the New Objective:**
- The new objective function is:
\[ J_{\text{new}}(w) = 2 \sum_{i=1}^n (x_i^T w - y_i)^2 + \sum_{j=1}^{10} (\tilde{x}_j^T w - \tilde{y}_j)^2 \]
- At \( w = w^* \), the first term achieves its global minimum \( 2 \sum_{i=1}^n (x_i^T w^* - y_i)^2 \), and the second term is \( \sum_{j=1}^{10} (\tilde{x}_j^T w^* - \tilde{y}_j)^2 = 0 \) (which is also the minimum possible value of a sum of squares, since squares are non-negative).
- Because \( w^* \) simultaneously minimizes both non-negative parts of \( J_{\text{new}}(w) \), the optimal solution \( w_{\text{new}}^* \) remains \( w^* \).
**Answer: TRUE.**
A: **Correct:** Duplicating the original points scales the original loss by 2, and the 10 new points have zero residual at \( w^* \), so \( w^* \) simultaneously minimizes both terms of the new objective.
B: **Incorrect:** Because the new points have zero error at \( w^* \) and duplicating all original points only multiplies the original objective by 2, the minimizer does not change.
**1. Relate Gaussian Conditional Log-Likelihood to Sum of Squared Errors:**
- In the linear regression model \( y = w^T x + \epsilon \) with \( \epsilon \sim \mathcal{N}(0, \sigma^2) \), the conditional distribution of \( y_i \) given \( x_i \) is \( \mathcal{N}(w^T x_i, \sigma^2) \).
- For \( n \) independent observations, the conditional log-likelihood of \( w \) is:
\[ \ell(w) = \sum_{i=1}^n \log p(y_i \mid x_i; w) = -\frac{n}{2}\log(2\pi\sigma^2) - \frac{1}{2\sigma^2}\sum_{i=1}^n (y_i - w^T x_i)^2 = -\frac{n}{2}\log(2\pi\sigma^2) - \frac{1}{2\sigma^2}\|y - X^T w\|_2^2 \]
- Since \( -\frac{n}{2}\log(2\pi\sigma^2) \) is constant with respect to \( w \) and \( \frac{1}{2\sigma^2} > 0 \), maximizing \( \ell(w) \) with respect to \( w \) is mathematically equivalent to minimizing \( \|y - X^T w\|_2^2 \).
**Answer: TRUE.**
A: **Correct:** Under zero-mean i.i.d. Gaussian noise \( \mathcal{N}(0, \sigma^2) \), the log-likelihood is a negative linear function of the sum of squared residuals \( \|y - X^T w\|_2^2 \), so maximizing log-likelihood is equivalent to minimizing \( \|y - X^T w\|_2^2 \).
B: **Incorrect:** The equivalence holds directly from the exponent of the Gaussian probability density function.
**1. Analyze the Column Space Projection (\( X^T w^* \)):**
- Here \( X \in \mathbb{R}^{d \times n} \) has \( d \) rows (features) and \( n \) columns (data points), so \( X^T \in \mathbb{R}^{n \times d} \) has \( d \) columns in \( \mathbb{R}^n \), where each column of \( X^T \) corresponds to one feature across the \( n \) samples.
- Minimizing \( \|X^T w - y\|_2^2 \) projects the label vector \( y \in \mathbb{R}^n \) orthogonally onto the column space of \( X^T \), which is the subspace spanned by the \( d \) features. Thus \( X^T w^* \) is the projection of the labels onto the subspace spanned by the features (**Option A is true**, Option B is false).
**2. Analyze the Normal Equations for \( w^* \):**
- By the normal equations (taking the minimum-norm least squares solution), \( X X^T w^* = X y \).
- Even more generally, any component of \( w \) orthogonal to the column space of \( X \) (the span of the data points \( x_1, \dots, x_n \in \mathbb{R}^d \)) lies in the nullspace of \( X^T \) and does not affect \( X^T w \). The minimum-norm/standard solution \( w^* = X \alpha \) lies in the column space of \( X \), which is the **span of the data points** in \( \mathbb{R}^d \) (**Option C is true**, Option D is false).
**Answer: Options A and C.**
A: **Correct:** \( X^T w^* \in \mathbb{R}^n \) is a linear combination of the columns of \( X^T \) (the feature vectors across samples), representing the orthogonal projection of \( y \) onto the subspace spanned by the features.
B: **Incorrect:** The data points are columns of \( X \) in \( \mathbb{R}^d \), whereas \( X^T w^* \) lies in \( \mathbb{R}^n \) (the span of the feature columns of \( X^T \)).
C: **Correct:** From \( X X^T w^* = X y \), the optimal weight vector \( w^* \in \mathbb{R}^d \) is a linear combination of the columns of \( X \), so it lies in the span of the data points.
D: **Incorrect:** The features are vectors in \( \mathbb{R}^n \), whereas \( w^* \in \mathbb{R}^d \) lies in the span of the data points.
**1. Compare Generative and Discriminative Models:**
- **Generative Models:** Model the class-conditional distribution \( p(x \mid y) \) and prior \( p(y) \) (or joint distribution \( p(x, y) \)), capturing **how the features \( x \) are generated** given the label \( y \), and then use Bayes' rule to find \( p(y \mid x) \). Examples include Gaussian Naive Bayes, LDA, and GMMs. (**Option A is true**, Options D and E are false).
- **Discriminative Models:** Directly model the conditional probability \( p(y \mid x) \) (or learn a decision boundary directly) without modeling how the features \( x \) are generated. Examples include Logistic Regression and SVMs. (**Option C is true**, Option B is false).
**Answer: Options A and C.**
A: **Correct:** Generative models learn the joint/class-conditional distribution \( p(x \mid y) \), modeling how the features are generated.
B: **Incorrect:** Discriminative models do not model how features are generated; they directly model \( p(y \mid x) \).
C: **Correct:** Discriminative models directly estimate the posterior class probability \( p(y \mid x) \).
D: **Incorrect:** Modeling \( p(y \mid x) \) directly is the objective of a discriminative model, whereas generative models model \( p(x \mid y) \) and \( p(y) \).
E: **Incorrect:** Gaussian Naive Bayes models \( p(x \mid y) \) and \( p(y) \), making it a generative model, not a discriminative model.
Based on the above data, answer the given subquestions.
Which among the following represents the correct decision boundary for the decision tree?
**Note:** Here + represents the label 1 and − represents the label 0.
Based on the above data, answer the given subquestions.
What will be the prediction for the new datapoint (2, 2)?
Published solution
**1. Trace the Datapoint \( (f_1, f_2) = (2, 2) \) Through the Decision Tree:**
- **Root Node (\( f_1 \le 1.5 \)):** Since \( f_1 = 2 > 1.5 \), we follow the **No** branch to the right child node.
- **Right Child Node (\( f_2 < 0 \)):** Since \( f_2 = 2 \not< 0 \), we follow the **No** branch to the right leaf node.
- **Leaf Node:** The leaf node outputs class label **0**.
**Answer: 0.**
Suppose you want to build a decision tree to help diagnose a certain disease based on patient
data. You have a dataset of 1000 patients labeled as either “positive” or “negative”. Here, positive
represents patients with the disease and negative represents no disease. One of the feature used
to diagnose is headache.
Below is the breakdown of the patients reporting headache:
Headache present: 300 positive, 50 negative
Headache not present: 100 positive, 550 negative
Based on the above data, answer the given subquestions.
What is the entropy of the root node? Enter the answer correct to two decimal places.
Published solution
**1. Find Class Proportions at the Root Node:**
- Total patients = \( 1000 \).
- Total positive patients = \( 300 + 100 = 400 \implies p_+ = \frac{400}{1000} = 0.4 \).
- Total negative patients = \( 50 + 550 = 600 \implies p_- = \frac{600}{1000} = 0.6 \).
**2. Calculate the Root Entropy:**
- Using the given values \( \log_2(0.4) = -1.32 \) and \( \log_2(0.6) = -0.74 \):
\[ H(\text{Root}) = -p_+ \log_2(p_+) - p_- \log_2(p_-) = -0.4(-1.32) - 0.6(-0.74) = 0.528 + 0.444 = 0.972 \approx 0.97 \]
**Answer: 0.97.**
Suppose you want to build a decision tree to help diagnose a certain disease based on patient
data. You have a dataset of 1000 patients labeled as either “positive” or “negative”. Here, positive
represents patients with the disease and negative represents no disease. One of the feature used
to diagnose is headache.
Below is the breakdown of the patients reporting headache:
Headache present: 300 positive, 50 negative
Headache not present: 100 positive, 550 negative
Based on the above data, answer the given subquestions.
What is the information gain for choosing the feature “headache” for splitting at the root node?
Enter the answer correct to two decimal places.
A published solution is not available for this question yet.