Implementing the Gradient Descent Algorithm in R
The negative gradient tells us that there is an inverse relationship between mpg and displacement with one unit increase in displacement resulting in a 0.04 unit decrease in mpg. How are these intercept and gradient values calculated one may ask? Each set of xy data points are iterated over to find the squared error, all squared errors are summed and the sum is divided by n to get the MSE. Next, we can calculate the MSE by summing the squared differences between observed yvalues and our predicted y values then dividing by the number of observations n. This gives a MSE of 9.911209 for this linear model.
Aug-10-2017, 19:25:05 GMT
- Technology: