← Back to AI Math Mind Map
📐 AI MathID: projection-least-squares

Projection & Least Squares

投影与最小二乘
🎯Core Definition
The least-squares problem min⁡w∥Xw−y∥2\min_w \Vert Xw - y \Vert^2 is, geometrically, an orthogonal projection: when y∉C(X)y \notin C(X) no exact solution exists, and the optimum requires XwXw to equal the orthogonal projection y^=Py\hat{y} = Py of yy onto the column space C(X)C(X), with residual r=y−Xwr = y - Xw orthogonal to C(X)C(X), i.e. XT(y−Xw)=0X^T(y - Xw) = 0, giving the normal equations XTXw=XTyX^TXw = X^Ty; with full column rank, w=(XTX)−1XTyw = (X^TX)^{-1}X^Ty. The projection matrix P=X(XTX)−1XTP = X(X^TX)^{-1}X^T is idempotent (P2=PP^2 = P) and symmetric (PT=PP^T = P), and I−PI - P projects onto N(XT)N(X^T). When XX is rank-deficient or XTXX^TX ill-conditioned, use the pseudoinverse X+=VΣ+UTX^+ = V\Sigma^+U^T (from the SVD; Σ+\Sigma^+ inverts nonzero singular values), giving the minimum-norm solution w=X+yw = X^+y.
💡Use Cases
closed-form solution of linear regression; line/polynomial fitting; recommenders, signal estimation, and solving overdetermined systems; the fallback when XTXX^TX fails due to collinearity or high dimensionality; also the starting point of Ridge regularization (XTX+λIX^TX + \lambda I).
⚡Key Problems Solved
with more equations than unknowns, yy typically lies outside C(X)C(X) and the system has no solution; the projection theorem guarantees that y^\hat{y}, with residual orthogonal to the column space, is the unique best approximation in the Euclidean norm; when XX is rank-deficient, (XTX)−1(X^TX)^{-1} does not exist and the pseudoinverse degenerates to the minimum-norm solution; moreover the normal equations square the condition number (κ(XTX)=κ(X)2\kappa(X^TX) = \kappa(X)^2), so the pseudoinverse/QR/SVD route is numerically far more stable.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Projection & Least Squares.
Use Cases
In production engineering, what are the primary use cases for Projection & Least Squares and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Derivation: from the residual orthogonality XT(y−Xw)=0X^T(y - Xw) = 0, derive the normal equations w=(XTX)−1XTyw = (X^TX)^{-1}X^Ty and sketch the projection geometry.
2
Prove P=X(XTX)−1XTP = X(X^TX)^{-1}X^T is an orthogonal projection (P2=PP^2 = P, PT=PP^T = P); onto which subspace does I−PI - P project?
3
By hand: fit a line y=w0+w1xy = w_0 + w_1x to 3 data points by constructing XX and yy and solving the normal equations.
4
When is XTXX^TX singular? How does the pseudoinverse X+=VΣ+UTX^+ = V\Sigma^+U^T yield the minimum-norm solution, and how does it differ from (XTX)−1XT(X^TX)^{-1}X^T?
5
Why are the normal equations numerically unstable (κ(XTX)=κ(X)2\kappa(X^TX) = \kappa(X)^2)? How do pseudoinverse, regularization, or QR mitigate collinearity?
📖 In-depth Guide:📄 linear-algebra-for-ai →
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Projection & Least Squares"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardSVD & Eigen-DecompositionNext Card →Matrix Decomposition Applications

🔗 More AI Math Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/Math/card/projection-least-squares
中文速览与面试要点

投影与最小二乘 (Projection & Least Squares)

定义: 线性最小二乘 _w Xw - y ^2 的几何本质是正交投影: 当 y C(X) 时无精确解, 最优解要求 Xw 等于 y 在列空间 C(X) 上的正交投影 y = Py, 残差 r = y - Xw 与 C(X) 正交, 即 X^T(y - Xw) = 0, 展开得正规方程 X^TXw = X^Ty; X 列满秩时 w = (X^TX)^-1X^Ty。投影矩阵 P = X(X^TX)^-1X^T 满足幂等 P^2 = P 与对称 P^T = P, I - P 是到 N(X^T) 的投影。当 X 秩亏或 X^TX 病态时, 改用伪逆 X^+ = V ^+U^T (由 SVD 定义, ^+ 对非零奇异值取倒数), 解 w = X^+y 给出最小范数解。 使用场景: 线性回归的闭式解; 数据点拟合 (直线/多项式); 推荐系统、信号估计、超定方程组求解; 特征共线或高维 (列相关) 时正规方程失效的替代; 也是 Ridge 正则化 (X^TX + I) 的出发点。 解决的问题: 方程数多于未知数时 y 常不在 C(X) 中, 方程组无解; 投影定理保证"残差与列空间正交"的 y 是唯一的最优近似, 且正交投影在欧氏范数下误差最小; 秩亏时 (X^TX)^-1 不存在, 伪逆自动退化为最小范数解; 直接解正规方程还会把条件数平方 ( (X^TX) = (X)^2), 伪逆/QR/SVD 路径数值上更稳。

核心要点

  • 推导: 从残差正交条件 X^T(y - Xw) = 0 手推正规方程 w = (X^TX)^-1X^Ty, 画出投影几何示意图?
  • 证明 P = X(X^TX)^-1X^T 是正交投影矩阵 (P^2 = P, P^T = P), 并说明 I - P 投影到哪个子空间?
  • 手算: 给定 3 个数据点拟合直线 y = w_0 + w_1x, 构造 X 与 y, 用正规方程解出 w?
  • X^TX 何时不可逆? 秩亏时伪逆 X^+ = V ^+U^T 如何给出最小范数解, 与 (X^TX)^-1X^T 有何区别?
  • 为什么正规方程数值不稳 ( (X^TX) = (X)^2)? 共线特征时如何缓解 (伪逆/正则化/QR)?