What is the objective function of Ordinary Least Squares (OLS)?

Quick Overview

Asks for the objective function that ordinary least squares minimizes when fitting a linear regression. Tests whether you can write it in summation and matrix form, explain why it has a closed-form minimizer, and connect it to maximum likelihood under an error model.

What is the objective function of Ordinary Least Squares (OLS)?

Role: Data Scientist

Category: Machine Learning

Difficulty: easy

Interview Round: Other

What is the objective function of Ordinary Least Squares (OLS)? Take a linear regression model $y = X\beta + \varepsilon$ fitted to $n$ observations, where each row $x_i^\top$ of $X$ holds the features of one observation. ```hint Start from one observation Write the error the model makes on a single observation, then decide how to combine those errors across all $n$ rows so that positive and negative errors do not cancel. ``` ### What a Strong Answer Covers - The objective written out, in summation form and in matrix form, with a clear definition of the residual. - What distance the objective measures and why the residuals are squared. - Convexity and differentiability, and what they imply for finding the minimizer. - The link between minimizing this objective and maximum likelihood under an assumed error distribution. ### Follow-up Questions - Derive the normal equation from the objective. When does $X^\top X$ fail to be invertible, and what happens to the solution then? - How do ridge and lasso change the objective, and what does each penalty do to the coefficients? - Why is OLS sensitive to outliers, and which loss would you use instead? - Does minimizing the mean of squared residuals instead of the sum change the fitted coefficients?

Overview: Asks for the objective function that ordinary least squares minimizes when fitting a linear regression. Tests whether you can write it in summation and matrix form, explain why it has a closed-form minimizer, and connect it to maximum likelihood under an error model.

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

What is the objective function of Ordinary Least Squares (OLS)?

Take a linear regression model y=Xβ+εy = X\beta + \varepsilon fitted to nn observations, where each row xi⊤x_i^\top of XX holds the features of one observation.

What a Strong Answer Covers Guidance

  • The objective written out, in summation form and in matrix form, with a clear definition of the residual.
  • What distance the objective measures and why the residuals are squared.
  • Convexity and differentiability, and what they imply for finding the minimizer.
  • The link between minimizing this objective and maximum likelihood under an assumed error distribution.

Follow-up Questions Guidance

  • Derive the normal equation from the objective. When does X⊤XX^\top X fail to be invertible, and what happens to the solution then?
  • How do ridge and lasso change the objective, and what does each penalty do to the coefficients?
  • Why is OLS sensitive to outliers, and which loss would you use instead?
  • Does minimizing the mean of squared residuals instead of the sum change the fitted coefficients?