-Normal equation
So far, the gradient descent algorithm has been used in linear regression problems, but for some linear regression problems, the normal equation method is a better solution.
The normal equation is solved by solving the following equations to find the parameters that make the cost function least:
Assuming our training set feature matrix is x, our training set results are vector y, then the normal equation is used to solve the vector:
The following table shows the data as an example:
The normal equation method is used to solve the parameters:
Note: The normal equation method is not available for those non-reversible matrices (usually because the features are not independent of each other, such as dimensions that include both feet and meters in size two features, or because the number of features is greater than the number of training sets).
The comparison of gradient descent with the normal equation is as follows:
Coursera Machine Learning Study notes (12)