MACHINE LEARNING
106403Module 2: Linear Models and Bayesian Learning
Q1c. What makes the difference between good decisions and bad decisions? (i) A good decision is based on logic (ii) A good decision considers all available data (iii) A good decision considers all alternatives (iv) A good decision applies quantitative approaches20222m
Module 2: Linear Models and Bayesian Learning
View this question on its own page →What makes the difference between good decisions and bad decisions?
(i) A good decision is based on logic
(ii) A good decision considers all available data
(iii) A good decision considers all alternatives
(iv) A good decision applies quantitative approachesWorked SolutionAnswer: (iv) A good decision applies quantitative approaches — though in ML/decision theory all (i)-(iii) also contribute, expected exam answer is (iv).
Explanation:
In Statistical Decision Theory / ML:
- Good decisions are not just based on logic (i) alone — logic without data is insufficient.
- Considering all data (ii) and all alternatives (iii) are part of rational decision making, but alone not distinctive.
- Quantitative approaches (iv) — using probability, expected loss/risk , utility, optimization — differentiate good from bad decisions objectively. This aligns with Bayesian decision theory, where you choose action .
Textbook often phrases: "A good decision is based on logic, considers all available data and alternatives, and applies quantitative approaches." If single best is asked, (iv) captures the statistical/ML perspective (quantitative risk minimization) that the other options miss. If multiple correct, (ii)+(iii)+(iv) would be joint.
Q1d. Where does the Bayes rule can be used? (i) Solving queries (ii) Increasing complexity (iii) Decreasing complexity (iv) Answering probabilistic query20222m
Module 2: Linear Models and Bayesian Learning
View this question on its own page →Where does the Bayes rule can be used?
(i) Solving queries
(ii) Increasing complexity
(iii) Decreasing complexity
(iv) Answering probabilistic queryWorked SolutionAnswer: (iv) Answering probabilistic query — (i) Solving queries is also acceptable but (iv) is more precise.
Explanation:
Bayes Rule:
Uses:
- Answering probabilistic queries — compute posterior , e.g., .
- Solving queries in Bayesian networks: Inference via enumeration, variable elimination, MCMC.
- Classification (Naive Bayes):
- Updating beliefs with evidence, spam filtering, medical diagnosis.
It does NOT increase/decrease complexity inherently; it enables probabilistic reasoning.
Hence (iv) Answering probabilistic query is textbook best. (i) Solving queries is vague but related — if single choice forced, pick (iv).
Q1e. Which of the following steps/assumptions in regression modeling impacts the trade-off between under-fitting and over-fitting the most? (i) The polynomial degree (ii) Whether we learn the weights by matrix inversion or gradient descent (iii) The use of a constant-term (iv) None of the above20222m
Module 2: Linear Models and Bayesian Learning
View this question on its own page →Which of the following steps/assumptions in regression modeling impacts the trade-off between under-fitting and over-fitting the most?
(i) The polynomial degree
(ii) Whether we learn the weights by matrix inversion or gradient descent
(iii) The use of a constant-term
(iv) None of the aboveWorked SolutionAnswer: (i) The polynomial degree
Explanation — Underfitting vs Overfitting trade-off:
Model complexity controls bias-variance trade-off. Polynomial degree directly controls capacity:
- Degree=1 (linear) — high bias, may underfit non-linear data
- Degree too high (e.g., 10 for 20 points) — low bias but high variance, overfits noise, oscillates
(ii) Whether we learn weights by matrix inversion vs gradient descent — Both solve same optimization vs iterative; they reach same (if convex), so no impact on generalization.
(iii) Use of constant-term (bias ) — Important to fit intercept, but small impact compared to degree. Without bias, model forced through origin — may underfit slightly, but not as dramatic as degree change.
Thus degree (i) is the dominant hyperparameter governing over/under-fitting.
Other factors affecting trade-off: regularization , training set size, early stopping.
Q3a. What is Linear Regression? Explain in detail using example and list all the assumption to be met before starting with linear regression.20237m
Module 2: Linear Models and Bayesian Learning
View this question on its own page →What is Linear Regression? Explain in detail using example and list all the assumption to be met before starting with linear regression.
Worked SolutionLinear Regression:
Model: , with . Goal: learn minimizing squared loss or MLE under Gaussian noise.
Closed form: (OLS). Gradient descent also: $w:=w-\eta
abla J$.Example: Predict house price (in lakhs) from size (sq ft). Data: (1000,50), (1500,70), (2000,90) → learn → for 1200 sq ft predict L.
Types: Simple (one predictor), Multiple (many), Polynomial (features but linear in parameters).
Assumptions to be met before Linear Regression:
- Linearity: Relationship between and is linear (check scatter plot, residuals vs fitted).
- Independence of errors: Observations independent (no autocorrelation, Durbin-Watson).
- Homoscedasticity: Constant variance of residuals (Breusch-Pagan test).
- Normality of residuals: for inference (Q-Q plot, Shapiro-Wilk) — not strictly for prediction.
- No multicollinearity: Predictors not highly correlated (VIF <5-10).
- No autocorrelation and no endogeneity ().
- No influential outliers (Cook's distance).
- Features not random, measured without error, sample size .
Checks/Remedies: Transform variables (log), remove outliers, ridge if multicollinearity, Weighted LS if heteroscedasticity. Violations bias estimates / invalidate p-values.
Q3b. What is regression analysis? What are the differences between linear regression and ridge regression?20227m
Module 2: Linear Models and Bayesian Learning
View this question on its own page →What is regression analysis? What are the differences between linear regression and ridge regression?
Worked SolutionRegression Analysis: Statistical process for estimating relationships among variables. Predict continuous dependent from independent . Model . Used for prediction, inference of variable importance, trend estimation.
Types: Simple linear, multiple linear, polynomial, ridge/lasso, logistic (classification), non-linear.
Linear Regression:
- Model: ,
- Assumes linear relationship, homoscedasticity.
- OLS solution:
- Loss:
- Suffers when singular/multicollinear, overfits with many features, sensitivity to outliers.
Ridge Regression (L2 Regularized):
- Loss: ,
- Solution:
- Adds bias but reduces variance (bias-variance trade-off), handles multicollinearity by shrinking coefficients, always invertible.
- Does feature shrinkage, not selection (all non-zero). Lasso () does selection.
Aspect Linear Ridge Penalty none Coefficients unbiased, high variance if collinear biased (shrink toward 0), lower variance When fails works Hyperparameter none via CV Interpretability direct shrunk values Ridge is preferred when multicollinearity, high dimensional or overfitting risk.
Q5b. A patient takes a lab test and the result comes back positive. It is known that the test returns a correct positive result in only 98% of the cases and a correct negative result in only 97% of the cases. Furthermore, only 0.008 of the entire population has this disease. (i) What is the probability that this patient has cancer? (ii) What is the probability that he does not have cancer? (iii) What is the diagnosis?20237m
Module 2: Linear Models and Bayesian Learning
View this question on its own page →A patient takes a lab test and the result comes back positive. It is known that the test returns a correct positive result in only 98% of the cases and a correct negative result in only 97% of the cases. Furthermore, only 0.008 of the entire population has this disease.
(i) What is the probability that this patient has cancer?
(ii) What is the probability that he does not have cancer?
(iii) What is the diagnosis?Worked SolutionGiven: Test correct positive (sensitivity), correct negative $P(-|
eg D)=0.97P(+|
eg D)=0.03P(D)=0.008$.We compute posterior using Bayes: where $P(+)=P(+|D)P(D)+P(+|
eg D)P(
eg D)$.- , $P(
eg D)=0.992$ - , $P(+|
eg D)=1-0.97=0.03$
(i)
**(ii) $P(
eg D|+) =1 -0.2085=0.7915 \approx 79.2%0.02976/0.0376=0.7915$)(iii) Diagnosis: Despite positive test, patient most probably does NOT have cancer/disease (about 79% chance healthy) because disease is rare (base rate fallacy). Positive predictive value only ~21%. Recommend further testing (more specific test, follow-up) — do not immediately diagnose cancer. If used as MAP classifier, predict $
eg D$ (no cancer).Note: This classic low-prevalence paradox shows importance of prior. If prevalence higher, posterior rises sharply.
- , $P(
Q9a. Write short notes on the following: (a) Partial least square20227m
Module 2: Linear Models and Bayesian Learning
View this question on its own page →Write short notes on the following:
(a) Partial least squareWorked Solution(a) Partial Least Squares (PLS):
PLS is dimensionality reduction + regression method for high-dimensional, multicollinear, data (e.g., chemometrics, genomics).
Goal: Find latent components that maximize covariance between (predictors) and (responses), not just variance of like PCA.
Idea: Decompose , with , latent scores, weights maximize .
Algorithm (NIPALS):
- Center/scale .
- For component : compute weight (for univariate ) normalized, , , , deflate , .
- Regression yields .
Types: PLS1 ( univariate), PLS2 ( multivariate), PLS-DA (classification).
Advantages: Handles multicollinearity, , noisy predictors, stable; gives interpretable latent factors (like PCA but supervised).
Vs PCA/OLS: PCA maximizes , PLS maximizes → better predictive components. OLS fails when singular; PLS works.
Choosing components : Cross-validation (Q² metric).
Example: Predict chemical concentration from 1000-wavelength spectra (highly correlated) with 50 samples → PLS finds 3 latent factors capturing predictive spectra shape.