Normal Equation
Analytic solution for Linear Regression
Assuming you have these training data points:
| 2104 | 5 | 1 | 45 | 460 |
| 1416 | 3 | 2 | 40 | 232 |
| 1534 | 3 | 2 | 30 | 315 |
| 852 | 2 | 1 | 36 | 178 |
Add an additional column with value 1 and turn the examples into a matrix, and the results into a vector
Then you can calculate
In Octave
pinv(X'*X)*X'*y
(use pseudo-inverse to avoid non-invertibility problems with )
- Could happen because of redundant (linear dependent) features or too many features for too few data points