What is the closed-form solution of ridge regression?

Quick Overview

Asks for the closed-form solution of ridge regression and how it is derived. Tests matrix calculus, why the L2 penalty guarantees a unique solution, intercept handling, and the numerical choices behind a practical ridge solver.

What is the closed-form solution of ridge regression?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

What is the closed-form solution of ridge regression? Take the usual setup: a design matrix $X$ with $n$ rows and $p$ features, a response vector $y$, and a penalty weight $\lambda > 0$ on the squared norm of the weights. ```hint Set the gradient to zero Write the objective as the sum of squared residuals plus λ times the squared norm of the weights, differentiate with respect to the weight vector, and solve the resulting linear system. ``` ### What a Strong Answer Covers - The penalized objective and the closed-form estimate - The derivation from the gradient, and why the solution is the unique minimum - Why adding λI makes the system solvable even with collinear features or more features than rows - How the intercept is handled - Numerical and computational choices, including solving instead of inverting and the dual form when p is much larger than n ### Follow-up Questions - How does the solution look in terms of the SVD of $X$, and which directions are shrunk most? - Show that the primal and dual forms give the same weights. - How would you choose λ, and is there a cheap way to compute leave-one-out error for ridge? - How does the closed form change if each feature gets its own penalty, or if samples carry weights?

Overview: Asks for the closed-form solution of ridge regression and how it is derived. Tests matrix calculus, why the L2 penalty guarantees a unique solution, intercept handling, and the numerical choices behind a practical ridge solver.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

What is the closed-form solution of ridge regression?

Take the usual setup: a design matrix XX with nn rows and pp features, a response vector yy, and a penalty weight λ>0\lambda > 0 on the squared norm of the weights.

What a Strong Answer Covers Guidance

  • The penalized objective and the closed-form estimate
  • The derivation from the gradient, and why the solution is the unique minimum
  • Why adding λI makes the system solvable even with collinear features or more features than rows
  • How the intercept is handled
  • Numerical and computational choices, including solving instead of inverting and the dual form when p is much larger than n

Follow-up Questions Guidance

  • How does the solution look in terms of the SVD of XX , and which directions are shrunk most?
  • Show that the primal and dual forms give the same weights.
  • How would you choose λ, and is there a cheap way to compute leave-one-out error for ridge?
  • How does the closed form change if each feature gets its own penalty, or if samples carry weights?