Back to Classic ML Mind Map
中文·English
📊 Classic MLID: linear-regression

Linear Regression OLS

线性回归 OLS
🎯Core Definition
Linear regression (OLS) assumes y=Xw+εy = Xw + \varepsilon and minimizes the residual sum of squares L(w)=yXw22L(w) = \Vert y - Xw\Vert_2^2. Differentiating gives Lw=2XT(Xwy)\frac{\partial L}{\partial w} = 2X^T(Xw - y); setting it to zero yields the normal equation XTXw=XTyX^TXw = X^Ty, with closed-form solution w=(XTX)1XTyw = (X^TX)^{-1}X^Ty when XX has full column rank — complexity about O(nd2+d3)O(nd^2 + d^3), so gradient descent (O(nd)O(nd) per step) wins in high dimensions. The 5 Gauss-Markov assumptions: (1) linearity in parameters, (2) zero conditional mean E[εX]=0E[\varepsilon \mid X] = 0 (exogeneity), (3) homoscedasticity Var(ε)=σ2IVar(\varepsilon) = \sigma^2 I, (4) independent errors, (5) no perfect multicollinearity (rank(X)=drank(X) = d); normally distributed errors additionally validate small-sample t/F inference.
💡Use Cases
baseline for regression tasks; interview staples include whiteboard-deriving the normal equation, discussing what to do when XTXX^TX is singular (pseudo-inverse, ridge with λI\lambda I, dropping collinear features), and comparing OLS vs gradient descent complexity.
Key Problems Solved
L(w)L(w) is convex quadratic (Hessian =2XTX0= 2X^TX \succeq 0), so the normal equation reaches the unique global optimum in one shot without tuning a learning rate; unlike non-parametric kkNN, OLS yields interpretable coefficients (wjw_j = marginal effect of xjx_j holding others fixed). When assumptions break (collinearity → ill-conditioned XTXX^TX; heteroscedasticity → wrong standard errors), switch to ridge or weighted least squares.
🎯5 High-Frequency Exam Points
1
Whiteboard the normal equation: expand L(w)=yXw2L(w) = \Vert y - Xw\Vert^2, take the gradient, set it to 0, and arrive at w=(XTX)1XTyw = (X^TX)^{-1}X^Ty; what condition makes XTXX^TX invertible?
2
What are the 5 OLS assumptions? What happens to unbiasedness, efficiency and consistency when each is violated?
3
What if XTXX^TX is singular or ill-conditioned? Compare pseudo-inverse, ridge w=(XTX+λI)1XTyw = (X^TX + \lambda I)^{-1}X^Ty and dropping collinear features.
4
State the Gauss-Markov theorem: under the 5 assumptions OLS is BLUE — why is normality not among them?
5
Derive the normal equation's complexity (building XTXX^TX is O(nd2)O(nd^2), inversion O(d3)O(d^3)) and explain why high-dimensional sparse settings prefer gradient descent.
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Linear Regression OLS"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Next CardVIF Multicollinearity

🔗 More Classic ML Knowledge Cards

AdaBoost DerivationBagging & Random ForestBaum-Welch (HMM EM)GBDT Negative Gradient