In our previous article we seen how to calculate linear regression by hand, in this article we will discuss how to find the accuracy of our linear regression model which we build.
Below are the metrics we need to calculate to check our model accuracy.
- R^2 (Coefficient of Determination)
- Adjusted R^2
- MSE
- RMSE
First, we need to know how accuracy of our model will be calculated ?!!!, Simple we already build our equation Y = mX+c , now calculate the value of Y with the know dataset as shown below.
If you observe the below data between Sugar level(Y) and Predicted Y
1)R Square (Coefficient of Determination)
It is one of the accuracy metrics in Linear Regression which is widely used. We can calculate R^2 in two ways as shown below.
Where is the mean of our actual dataset,,
is the predicted value with given dataset and
is mean of the predicted dataset.
As said we have two ways of calculating R Square, we will see both the ways.
=183.9225208/656 = 0.280369696
= 1 – 471.863 / 656 = 0.280369696
So by above R Square value I can say our model accuracy is 28%, as we have very less amount of data this accuracy is fine, we will also see how to improve the model accuracy in this blog.
2) Adjusted R Square
Why should I go for Adjusted R square if I have R Square? based on our accuracy(R Square) we might go for adding or removing observations/variables to improve our model accuracy, in this process the value of R Square will increase/decrease, so to identify the change in accuracy after added or removed variables/observation we will calculate Adjusted R Square the values will change only if the variables added or removed has some benefits .
Like R Square we have many ways to calculate Adjusted R square we will see one of them to calculate with below formula.
R squared and Adjusted R Square will not be same. Adjusted R Square should be always less than R Square.
3) Mean Squared Error and Root Mean Squared Error :
MSE and RMSE is one of the most used to calculate accuracy, it is always non-negative, and values closer to zero are better.
We already have SSE value as 471.863 and N is number of observation which is 6 in our case
So the value of RMSE and MSE is 78.64 and 6184.85 accordingly
Accuracy metrics will help only to identify how accuracy is our model, to increase the model accuracy we have many methods like
- Dimensional/variable reduction
- gradient(to increase the accuracy or to decrease the Cost function)
- Regularization (to reduce the over fitting)
One thought on “Calculating Accuracy”