Linear regression and gradient descent: past questions

23 questions · 69 marks · 9 papers. Try each one before checking.

Solve them and check answers →Read the notes first

Aug 2023 (day not given)

Question Q2 MCQ · 4 marks

Consider a training dataset of $n$ points for a regression problem. Assume that the model is linear. Let $w_1$ and $w_2$ be the optimal weight vectors obtained from solving $w_1=\arg\min_w\sum_{i=1}^n(w^Tx_i-y_i)^2$ and $w_2=\arg\min_w\sum_{i=1}^n(w^Tx_i-y_i)^3$. Choose the most appropriate answer.
  1. $w_1$ will generalize better than $w_2$ on the test dataset.
  2. $w_2$ will generalize better than $w_1$ on the test dataset.
  3. Both models will show identical performance on the test dataset.

Question Q4 MSQ · 4 marks

Consider a linear regression model trained on dataset $X$ of shape $(d,n)$. Which of the following techniques could potentially decrease the loss on the training data (assuming the loss is the squared error)?
  1. Adding a dummy feature in the dataset and learning the intercept $w_0$ as well.
  2. Penalizing the model weights with $L_2$ regularization.
  3. Penalizing the model weights with $L_1$ regularization.
  4. Training the kernel regression model of degree $2$.

Aug 2025 (03 Aug)

Question Q6 MCQ · 2 marks

Consider a dataset $D=\{(x_1,y_1),\dots,(x_n,y_n)\}$. Let $w^*\in\mathbb R^d$ be the solution of $\min_w\|X^Tw-y\|_2^2$, where $X\in\mathbb R^{d\times n}$, $y\in\mathbb R^n$. Construct a new dataset $D_{new}$ by duplicating all points in $D$ and adding $10$ new points that lie exactly on the line $y=x^Tw^*$. Then the solution $w^*_{new}$ of the corresponding optimisation problem is also $w^*$.
  1. TRUE
  2. FALSE

Question Q8 MSQ · 2 marks

Let $w^*\in\mathbb R^d$ be the solution of $\min_w\|X^Tw-y\|_2^2$, where $X\in\mathbb R^{d\times n}$, $y\in\mathbb R^n$. Which of the following statements is/are true?
  1. $X^Tw^*$ is the projection of the labels onto the subspace spanned by the features.
  2. $X^Tw^*$ is the projection of the labels onto the subspace spanned by the data points.
  3. $w^*$ lies in the span of data points.
  4. $w^*$ lies in the span of features.

Question Q2 MCQ · 4 marks

Consider $n$ data points, each feature $x_i\in\mathbb R^+$ and label $y_i\in\mathbb R$. Suppose $y_i\mid x_i\sim N(\log(wx_i),1)$. Find the ML estimate $\hat w_{MLE}$ of $w$, where $w>0$.
  1. $\hat w=\exp\!\big(\tfrac1n\sum_{i=1}^n(y_i-\log x_i)\big)$
  2. $\hat w=\exp\!\big(\tfrac1n\sum_{i=1}^n(x_iy_i-x_i\log x_i)\big)$
  3. $\hat w=\tfrac1n\sum_{i=1}^n(y_i-\log x_i)$
  4. $\hat w=\exp\!\big(\tfrac1n\sum_{i=1}^n(x_iy_i-\log x_i)\big)$

Question Q7 MCQ · 1 marks

Consider the linear regression model $y=w^Tx+\epsilon$. Assuming $\epsilon\sim N(0,\sigma^2)$, maximising the conditional log-likelihood of $w$ is equivalent to minimising the sum of squared errors $\|y-X^Tw\|_2^2$.
  1. TRUE
  2. FALSE

Apr 2026 (06 Apr)

Question Q1 MCQ · 3 marks

Consider a linear regression model applied to a dataset in which each data-point is described by two features. The first feature is always $1$. The $i$-th data-point's feature-label pair is $((1,x_i),y_i)$. Let $(w_0^*,w_1^*)\in\mathbb R^2$ be the optimal weight vector that minimises the sum of squared errors. Consider two scenarios: $S_1$: $w_0^*+w_1^*x_i>y_i$ for each data-point. $S_2$: $w_0^*+w_1^*x_i<y_i$ for each data-point. Which of the following is true?
  1. $S_1$ is possible, but $S_2$ is impossible.
  2. $S_1$ is impossible, but $S_2$ is possible.
  3. One of $S_1$ or $S_2$ is possible.
  4. Both $S_1$ and $S_2$ are impossible.

Aug 2026 (14 Aug)

Question Q4 MCQ · 4 marks

On a machine that folds plastic film, the operating temperature can be varied between $130^\circ$C and $185^\circ$C. To study the relationship between temperature and fold thickness, $n=12$ observations were collected. Scatter plot description: horizontal axis Temperature ($130$ to $185$), vertical axis Thickness (ticks $90$ to $130$). Twelve points closely follow a downward-sloping line from about $(130,135)$ to $(185,86)$.
Determine, by inspecting the figure, which set of parameter estimates for $\text{Thickness}=\beta_0+\beta_1(\text{Temperature})+\epsilon$, $\epsilon\sim N(0,\sigma^2)$, is most appropriate. ($\hat\beta_0$ intercept, $\hat\beta_1$ slope, $\hat\sigma$ estimated standard deviation of the error.)
  1. $\hat\beta_0=0,\ \hat\beta_1=-0.9,\ \hat\sigma=360$
  2. $\hat\beta_0=0,\ \hat\beta_1=0.9,\ \hat\sigma=3.6$
  3. $\hat\beta_0=252,\ \hat\beta_1=-0.9,\ \hat\sigma=3.6$
  4. $\hat\beta_0=-252,\ \hat\beta_1=-0.9,\ \hat\sigma=360$
  5. $\hat\beta_0=252,\ \hat\beta_1=-0.9,\ \hat\sigma=360$

Question Q8 MCQ · 3 marks

A dataset has $n=3$ data points and $d=2$ features. The two feature vectors are $f_1=[1,0,1]^T$, $f_2=[0,1,1]^T$. For which label vector $y$ is the linear model $f(x)=w^Tx$ guaranteed to achieve exactly zero training error?
  1. $y=[1,2,3]^T$
  2. $y=[1,2,4]^T$
  3. $y=[2,1,4]^T$
  4. $y=[0,0,1]^T$

Question Q9 MCQ · 3 marks

Suppose the label vector $y\ne0$ is orthogonal to every feature vector, i.e. $f_j^Ty=0$ for all $j=1,\dots,d$. $w^*$ is the optimal weight after minimising the linear regression objective. Which statement is correct?
  1. $X^Tw^*=y$ and the training error is $0$.
  2. $X^Tw^*=0$ and the squared training error equals $\|y\|_2^2$.
  3. $X^Tw^*=0$ and the squared training error equals $0$.
  4. The normal equations have no solution.

Question Q7 MCQ · 3 marks

A student $P$ minimises the sum of squared errors loss while another student $Q$ minimises the mean squared error loss $L(w)=\tfrac12\sum_{i=1}^n(w^Tx_i-y_i)^2$, $L'(w)=\tfrac1{2n}\sum_{i=1}^n(w^Tx_i-y_i)^2$. Both use gradient descent with the same learning rate $\eta$ and the same initial parameter vector $w_0$. Which statement is correct?
  1. They converge to different minimizers, because the losses differ.
  2. They converge to the same minimizer, but $Q$'s steps are $n$ times smaller; $Q$ would need learning rate $n\eta$ to reproduce $P$'s trajectory.
  3. They converge to the same minimizer, and their iterates coincide at every step.
  4. They converge to the same minimizer, but $Q$'s steps are $n$ times larger.

Question Q3 MCQ · 4 marks

Under the probabilistic view of linear regression, assume $y_i\sim N(w^Tx_i,\sigma^2)$ with independent observations. Suppose the true noise variance is $4\sigma^2$ instead of $\sigma^2$, while the dataset and the observed labels remain unchanged. What happens to the ML estimator $\hat w_{ML}=(XX^T)^{-1}Xy$?
  1. It is unchanged.
  2. It is scaled by $4$.
  3. It is scaled by $1/4$.
  4. It cannot be determined without knowing $\sigma^2$.

Dec 2024 (01 Dec)

Question Q21 MSQ · 3 marks

Consider a linear regression model with loss $L(w)=\sum_{i=1}^n(w^Tx_i-y_i)^2$, where $x_i$ are the $d$-dimensional training data points and $y_i$ their labels. For the optimal weight vector $w^*$, which among the following is correct?
  1. If we double all the values of $y_i$, $w^*$ will also get doubled.
  2. If we double all the values of $y_i$, $w^*$ will get halved.
  3. If we double all the values of $x_i$, $w^*$ will get halved.
  4. If we double all the values of $x_i$, $w^*$ will also get doubled.

Aug 2024 (04 Aug)

Question Q3 SA · 3 marks

Consider the following training dataset for a linear regression problem with one feature: $(x_i,y_i)=(1.2,1),(-1,0.1),(2.1,2),(-2,-1)$. Find the value of $w^*$, the optimal weight.

Type your answer on the interactive page.

Question Q7 SA · 2 marks

A linear regression problem has two features and $10{,}000$ training points. The blue point $w^{(t)}$ is the weight at some iteration of gradient descent. $w_1=\tfrac1{\sqrt{10}}(3,1)$, $w_2=\tfrac1{\sqrt{10}}(-3,-1)$, $w_3=\tfrac1{\sqrt{10}}(-1,3)$ are unit vectors; $w_1$ points in the direction of the gradient (figure described in words).
If the next iteration of gradient descent is expressed as $w^{(t+1)}=w^{(t)}+\eta w_k$ with $\eta>0$, what would be the value of $k$?

Type your answer on the interactive page.

Question Q8 SA · 2 marks

Same setting: $w_1=\tfrac1{\sqrt{10}}(3,1)$ is the unit vector along the gradient, $w_2=-w_1$, $w_3\perp w_1$.
If $w^{(t)}=\begin{bmatrix}0.4\\0.1\end{bmatrix}$ and $\eta=\tfrac1{\sqrt{10}}$, find $\|w^{(t+1)}\|$ where we use the usual $L_2$ norm.

Type your answer on the interactive page.

Mar 2024 (24 Mar)

Question Q6 MCQ · 3 marks

Predicting house sale prices from square footage with two models: Model $P$: $\hat y=w_0+w_1x$; Model $Q$: $\hat y=w_0+w_1x+w_2x^2$. The training set has $200$ houses; the test set has $50$ houses. Evaluation metric: mean squared error (MSE).
Considering the specific context of predicting house prices based on square footage, which model is more likely to provide accurate predictions on the training dataset?
  1. Model $P$
  2. Model $Q$
  3. Both models are equally likely to provide accurate predictions
  4. It depends on the distribution of house prices in the dataset

Question Q7 MSQ · 3 marks

Predicting house sale prices from square footage with two models: Model $P$: $\hat y=w_0+w_1x$; Model $Q$: $\hat y=w_0+w_1x+w_2x^2$. Training set: $200$ houses; test set: $50$ houses; metric: MSE.
Identify the factors that could influence the model's performance on the training dataset in this housing price prediction scenario. Select all correct statements:
  1. Model $P$ may struggle to capture non-linear relationships present in house price data.
  2. Model $Q$ might be sensitive to outliers in the square footage variable.
  3. The choice between Model $P$ and Model $Q$ depends on the budget constraints of potential homebuyers.
  4. Model $Q$ will always perform well on the test dataset.

Question Q16 MCQ · 3 marks

Let $X$ be the data matrix of shape $(d,n)$ and $y$ the corresponding label vector. A linear regression model $\hat y_i=w^Tx_i$ is fit using the squared error on the same dataset. If the solution $w^*$ is orthogonal to the subspace spanned by the data points (the columns of $X$), what will be the squared error?
  1. $0$
  2. $1$
  3. $\|y\|^2$
  4. Insufficient information to answer

Dec 2023 (day not given)

Question Q3 SA · 4 marks

Consider a training set $\{X,y\}$, where $X\in\mathbb R^{d\times n}$ and $y\in\mathbb R^n$. A team uses the linear regression model $h=w^TX$ that minimises $L(w)=\sum_{i=1}^n(w^Tx_i-y_i)^2$.
Let the dimensions be $d=3$ and $n=100$. What is the sum of the elements of $X(X^Tw-y)$? If you think the given information is insufficient, enter $-1$.

Type your answer on the interactive page.

Question Q5 SA · 4 marks

Consider a training set $\{X,y\}$ with $X\in\mathbb R^{d\times n}$ and $y\in\mathbb R^n$. A team uses the linear regression model that minimises $L(w)=\sum(w^Tx_i-y_i)^2$.
The team modifies the relation as $y=X^Tw+\epsilon$ where $\epsilon\sim N(0,\sigma^2)$. Suppose $\sigma^2=1$, $d=3$, $n=100$. Assume $\sum_{i=1}^n(w^Tx_i-y_i)^2=0$ for $w=w^*$. What is the negative log-likelihood of the dataset $(X,y)$ at $w^*$? Use logarithm to base $10$.

Type your answer on the interactive page.

Mar 2025 (16 Mar)

Question Q12 SA · 3 marks

Consider a linear regression model $y_i=w^Tx_i$ with an initial weight $w=[3]$.
Using the squared loss function and a learning rate of $\eta=0.2$, compute the updated weight after one iteration of gradient descent for the dataset $(x_1,y)=(1,4),(2,7),(3,10),(4,13)$. Use $\nabla f(w)=2(XX^T)w-2Xy$.

Type your answer on the interactive page.

Question Q13 SA · 2 marks

Same model as the previous question; the algorithm stops at the weight computed in the previous question ($w=7$).
What will be the predicted value for the data point $x_1=5$?

Type your answer on the interactive page.

Check your answers →

Weeks covering this topic

Other MLT topics