The derivation part was fine, I remembered enough calculus to get through it.
Start by clearly stating the linear regression model and MSE loss, then derive the gradient with respect to weights, set it to zero, and solve for the closed-form solution. Implement the closed-form solution in code, then implement gradient descent and compare the learned weights on a small synthetic dataset to verify correctness.
Pro tip: Mention that the closed-form solution requires inverting X^T X, which can be numerically unstable; suggest using np.linalg.solve or adding a small regularization term. Also, emphasize that gradient descent should converge to the same solution if the learning rate is appropriate and enough iterations are run.
State the linear model y = Xw + b (or include bias in X) and define MSE as (1/n) * sum((y_pred - y_true)^2).
Compute the gradient of MSE w.r.t. w, set it to zero, and solve for w = (X^T X)^{-1} X^T y. Show the steps clearly.
Code the closed-form expression using numpy, handling the bias term (e.g., by augmenting X with a column of ones).
Code gradient descent to minimize MSE, updating weights iteratively. Choose a learning rate and number of iterations.
Generate a small synthetic dataset, run both methods, and compare the resulting weights (and possibly loss curves) to ensure they match within a tolerance.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.