The inverse exists only for square, full-rank matrices; non-square or singular matrices use the pseudo-inverse (via SVD).
Linear regression's normal equation is w = (X transposed X) inverse times X transposed y, but in practice it is better to solve the linear system with a decomposition (QR, Cholesky) or use gradient descent, which is faster and more numerically stable.
Explicit inversion costs about n cubed operations and amplifies rounding errors when the matrix is ill-conditioned (a large condition number).
Loading…