# Machine Learning: Bias-Variance, L1/L2 Regularization & Confusion Matrix Metrics
Exam: GATE Data Science & Artificial Intelligence (DA) (GATE DA)
Subject: Machine Learning & Deep Learning
Canonical URL: https://gateandnet.com/exams/gate-da/machine-learning-and-ai/bias-variance-regularization-and-metrics

> Expected test MSE decomposition, why L1 Lasso induces sparsity while L2 Ridge shrinks smoothly, Precision/Recall/F1 & PCA.

## Ridge ($L_2$) vs. Lasso ($L_1$) Regularization

- **Ridge Regression ($L_2$ penalty $\lambda \|w\|_2^2$):** Closed-form solution $\hat{w}_{\text{ridge}} = (X^T X + \lambda I)^{-1} X^T y$. Always invertible for $\lambda > 0$ even when $X^T X$ is singular (collinearity)! Shrinks weights toward zero asymptotically without setting them to exact zero.
- **Lasso Regression ($L_1$ penalty $\lambda \|w\|_1$):** Diamond-shaped constraint polytope has sharp corners on coordinate axes $\implies$ drives irrelevant feature weights to **exact $0$** (automatic **Feature Selection**!).


## Solved Practice Questions & PYQs

### [GATE DA 2024 | MCQ]
In a binary classification task, a model achieves $\text{Precision} = 0.80$ and $\text{Recall} = 0.50$. What is the **$F_1$-score** of the classifier (rounded to two decimal places)?
**Correct Answer:** A
**Solution:** $$F_1 = \frac{2 \times 0.80 \times 0.50}{0.80 + 0.50} = \frac{0.80}{1.30} \approx \mathbf{0.6154 \approx 0.62}$$

### [GATE DA MSQ | MSQ]
Which of the following statements regarding **Regularization** and **Ensemble Learning** are **TRUE**?
**Correct Answer:** A,B,D
**Solution:** - **A (True):** Constrained/penalized weights cannot beat unconstrained OLS on training MSE.
- **B (True):** $-\ln p(w) \propto \sum |w_j|$ for a Laplace prior.
- **C (False):** Random Forests (Bagging) reduce **variance**, whereas Boosting reduces **bias**.
- **D (True):** Threshold splits $x_j \le t$ only depend on rank order!
