Error Calculation Techniques For Linear Regression

I hope you and your model are doing good !

Pratik Shukla
4 min readMay 18, 2020

There are various methods to calculate the accuracy of our model. In this article I’m going to cover a few of them. In this article we are not going to use python libraries to calculate accuracy of models, but instead we are going to do it from scratch. I hope you guys enjoy it.

In this article I’m going to use a user defined function to calculate the slope and intercept of a regression line. So if you haven’t read my previous article about it’s derivation then I think it’ll be for you to start with that. It won’t take more than 5 mins!!

So let’s get started!

(1) Initialize our dataset :

(2) Plot the data on scatterplot :

(3) Main function to calculate the slope and intercept :

(4) Print the slope and intercept values :

(5) Prediction function :

(6) Predicting our value :

(7) Plot the regression line :

Accuracy Of Model :

(1) Residual Sum Of Squares : (RSS)

RSS

(2) Mean Absolute Error : (MAE)

MAE

(3) Mean Squared Error : (MSE)

MSE

(4) Mean Absolute percentage Error (MAPE) :

MAPE

(5) Mean Percentage Error : (MPE)

MPE

(6) Root Mean Squared Error : (RMSE)

RMSE

So, that’s it for this article!

(1) Simple Linear Regression Explained With It’s Derivation:
https://youtu.be/1M2-Fq6wl4M

(2)How to Calculate The Accuracy Of A Model In Linear Regression From Scratch :
https://youtu.be/bM3KmaghclY

(3) Simple Linear Regression Using Sklearn :
https://youtu.be/_VGjHF1X9oU

Part 1 : Linear Regression From Scratch.

Part 2 : Linear Regression Line Through Brute Force.

Part 3 : Linear Regression Complete Derivation.

Part 4 : Simple Linear Regression Implementation From Scratch.

Part 5 : Simple Linear Regression Implementation Using Scikit-Learn.

If you have any additional questions; feel free to contact me shuklapratik22@gmail.com

To find more such detailed explanation, visit my blog: patrickstar0110.blogspot.com

--

--