Linear & Logistic Regression
Difficulty Level: 1 (Recognition — MCQ, Matching, True/False with justification) Time Limit: 20 minutes Total Marks: 30
Section A — Multiple Choice (1 mark each) [10 marks]
Q1. The simple linear regression model is written as . The term represents the:
- (a) slope
- (b) intercept
- (c) error term
- (d) residual variance
Q2. The sigmoid function used in logistic regression is:
- (a)
- (b)
- (c)
- (d)
Q3. The normal equation closed-form solution for linear regression coefficients is:
- (a)
- (b)
- (c)
- (d)
Q4. L1 (Lasso) regularization is preferred over L2 (Ridge) primarily because it:
- (a) always gives lower training error
- (b) can drive some coefficients exactly to zero (feature selection)
- (c) is differentiable everywhere
- (d) never overfits
Q5. The cost function most commonly minimized in linear regression is:
- (a) binary cross-entropy
- (b) mean squared error (MSE)
- (c) hinge loss
- (d) absolute intercept
Q6. For a classification task with more than two classes, the appropriate generalization of logistic regression is:
- (a) polynomial regression
- (b) softmax (multinomial) regression
- (c) ridge regression
- (d) simple linear regression
Q7. Which quantity always lies between 0 and 1 for an ordinary least squares fit (with intercept) and measures the proportion of variance explained?
- (a) MSE
- (b)
- (c)
- (d) log-loss
Q8. Elastic Net regularization combines:
- (a) MSE and cross-entropy
- (b) L1 and L2 penalties
- (c) softmax and sigmoid
- (d) gradient descent and normal equation
Q9. In gradient descent, the learning rate controls the:
- (a) number of features
- (b) step size of each parameter update
- (c) intercept value
- (d) number of classes
Q10. Polynomial regression fits a nonlinear curve while still being a linear model because it is linear in:
- (a) the input feature
- (b) the parameters (coefficients)
- (c) the output only
- (d) the learning rate
Section B — Matching (1 mark each) [8 marks]
Q11–Q18. Match each term in Column X with its correct description in Column Y. Write the letter.
| # | Column X | Column Y | |
|---|---|---|---|
| Q11 | Log-loss | A | Penalty term |
| Q12 | L2 penalty | B | Threshold in feature space separating predicted classes |
| Q13 | Decision boundary | C | Loss for binary classification: |
| Q14 | Adjusted | D | Adds features via powers of |
| Q15 | Multiple linear regression | E | Adjusts for number of predictors |
| Q16 | Polynomial regression | F | More than one input feature: |
| Q17 | Interpreting coefficient | G | Expected change in per unit change in , others fixed |
| Q18 | Sigmoid output | H | A probability between 0 and 1 |
Section C — True/False with Justification (2 marks each: 1 verdict + 1 justification) [12 marks]
Q19. True or False: One assumption of linear regression is that residuals are homoscedastic (constant variance). Justify.
Q20. True or False: Adding more predictors to a multiple regression model can never decrease the value. Justify.
Q21. True or False: The normal equation is always preferable to gradient descent regardless of the number of features. Justify.
Q22. True or False: In logistic regression, the decision boundary produced by a linear model is always a straight line/hyperplane in the original feature space. Justify.
Q23. True or False: Increasing the regularization strength in Ridge regression tends to shrink coefficient magnitudes toward zero. Justify.
Q24. True or False: Minimizing MSE for classification with a sigmoid output is preferred over log-loss because it is convex in the parameters. Justify.
Answer keyMark scheme & solutions
Section A — MCQ (1 mark each)
| Q | Ans | Why |
|---|---|---|
| Q1 | (b) | is the value of when — the intercept; is the slope. |
| Q2 | (b) | The logistic/sigmoid maps as . |
| Q3 | (a) | OLS minimizer: setting gives . |
| Q4 | (b) | The L1 penalty's non-smooth corners at zero produce sparse solutions (exact zeros). |
| Q5 | (b) | Regression minimizes mean squared error. |
| Q6 | (b) | Softmax/multinomial regression handles classes. |
| Q7 | (b) | (with intercept) = fraction of variance explained. |
| Q8 | (b) | Elastic Net = . |
| Q9 | (b) | scales the gradient step: . |
| Q10 | (b) | Model is linear in the , so OLS applies. |
Section B — Matching (1 mark each)
| Q | Ans |
|---|---|
| Q11 | C (log-loss / binary cross-entropy) |
| Q12 | A (L2 penalty = sum of squared coefficients) |
| Q13 | B (decision boundary) |
| Q14 | E (adjusted ) |
| Q15 | F (multiple linear regression) |
| Q16 | D (polynomial regression) |
| Q17 | G (coefficient interpretation, ceteris paribus) |
| Q18 | H (sigmoid → probability) |
Section C — True/False with Justification (1 + 1 marks)
Q19. TRUE. (1) Homoscedasticity — constant error variance across all fitted values — is a standard OLS assumption. (1) It ensures OLS estimators are efficient (BLUE) and that standard errors/inference are valid.
Q20. TRUE. (1) Adding predictors cannot decrease . (1) OLS can set new coefficients to zero, so the residual sum of squares can only stay equal or fall; hence is non-decreasing. (This is exactly why adjusted exists — to penalize added predictors.)
Q21. FALSE. (1) The normal equation is not always preferable. (1) Computing costs ~ and is unstable/infeasible for very large numbers of features; gradient descent scales better in high dimensions.
Q22. TRUE (in the given features). (1) True. (1) The boundary is where (i.e. ), which is a hyperplane linear in the features supplied. (Curved boundaries arise only if nonlinear/polynomial features are added — then it's still linear in the expanded feature space.)
Q23. TRUE. (1) Larger shrinks coefficients toward zero. (1) The penalty makes large coefficients costly; increasing raises that cost, forcing smaller magnitudes (though not exactly zero, unlike L1).
Q24. FALSE. (1) Log-loss is preferred, not MSE. (1) MSE with a sigmoid is non-convex in the parameters and can stall in flat regions; log-loss (cross-entropy) is convex for logistic regression, giving reliable optimization.
[
{"claim":"Sigmoid(0)=0.5","code":"z=symbols('z'); sig=1/(1+exp(-z)); result = (sig.subs(z,0)==Rational(1,2))"},
{"claim":"OLS normal equation solves X^T X beta = X^T y (2x2 identity design gives beta=X^T y)","code":"X=Matrix([[1,0],[0,1]]); y=Matrix([3,5]); beta=(X.T*X).inv()*X.T*y; result = (beta==Matrix([3,5]))"},
{"claim":"Ridge shrinks: for X=[[1]],y=[2],lambda=1 solution 2/(1+1)=1 < OLS 2","code":"lam=1; Xr=Matrix([[1]]); yr=Matrix([2]); b=(Xr.T*Xr+lam*eye(1)).inv()*Xr.T*yr; result = (b[0]==Rational(1,1)) and (Rational(1,1) < 2)"},
{"claim":"Elastic net penalty at beta=(1,-1) with l1=l2=1 equals 4","code":"b1,b2=1,-1; pen=(abs(b1)+abs(b2))+(b1**2+b2**2); result = (pen==4)"}
]