Transcription
Ordinary least squares has a beautiful closed form where beta equals X transpose X inverted times X transpose Y, but it hides a trap.
When two of your features are almost the same, this X transpose X matrix becomes nearly singular. Its determinant collapses toward zero, and inverting it sends the coefficients flying off to enormous untrustworthy values.
Ridge regression fixes this with one tiny change. Before inverting, it adds lambda times the identity, which is just a small constant running down the main diagonal. 100 quietly becomes 101. The determinant is suddenly healthy again, and the matrix can never be singular. So, the inverse stays calm, and every coefficient is gently pulled back toward zero.
And that little race strip we laid along the diagonal, that is literally where the name comes from. Ridge regression is just least squares with a ridge running down the diagonal.