Explain the "Normal Equation" for solving Linear Regression.

Quick Overview

Asks for an explanation of the normal equation used to fit linear regression coefficients in closed form. Tests the derivation from squared error, the projection view of least squares, invertibility and numerical stability, and when gradient descent is the better choice.

Explain the "Normal Equation" for solving Linear Regression.

Role: Data Scientist

Category: Machine Learning

Difficulty: easy

Interview Round: Other

Explain the "Normal Equation" for solving Linear Regression. ```hint Start from the loss Write the sum of squared errors in matrix form and find where its gradient with respect to the coefficient vector is zero. ``` ### What a Strong Answer Covers - The formula and what each term is, including the intercept column in the design matrix. - A derivation from the squared-error loss, or the geometric projection view. - When the matrix being inverted is singular and what to do then. - Computational cost and numerical stability compared with iterative methods such as gradient descent. ### Follow-up Questions - How does the normal equation change with L2 (ridge) regularization, and why does that also fix the invertibility problem? - Why do numerical libraries solve least squares with QR or SVD instead of forming an inverse? - With 10 million rows and 50 features, would you use the normal equation or gradient descent? What about 500,000 sparse features? - How would you compute the solution when the data does not fit in memory?

Overview: Asks for an explanation of the normal equation used to fit linear regression coefficients in closed form. Tests the derivation from squared error, the projection view of least squares, invertibility and numerical stability, and when gradient descent is the better choice.

General logo
General
Nov 24, 2026
easyData ScientistOtherMachine Learning
0
0

Explain the "Normal Equation" for solving Linear Regression.

What a Strong Answer Covers Guidance

  • The formula and what each term is, including the intercept column in the design matrix.
  • A derivation from the squared-error loss, or the geometric projection view.
  • When the matrix being inverted is singular and what to do then.
  • Computational cost and numerical stability compared with iterative methods such as gradient descent.

Follow-up Questions Guidance

  • How does the normal equation change with L2 (ridge) regularization, and why does that also fix the invertibility problem?
  • Why do numerical libraries solve least squares with QR or SVD instead of forming an inverse?
  • With 10 million rows and 50 features, would you use the normal equation or gradient descent? What about 500,000 sparse features?
  • How would you compute the solution when the data does not fit in memory?