Residual / Error

Linear Regression is a Supervised Learning Algorithm. Linear regression means a linear relationship between input and output variable i.e a straight line passing through actual points. In this we try to predict the output for unseen data based on the linear equation we derived.

Y = mx+ b   [ for single input ]

Y= m1x1+m2x2+.....mN xN+b  [ for multiple inputs ]

Here, Y is the output variable(predicted variable), x is the input variable, m is the slope, b is the Intercept of the line. We can adjust  the slope and intercept.

Residuals/ Error :

The distance between the actual values and predicted values. In the below diagram the star points are actual values and the points on the regression line are the predicted values. If the actual values are far from the regression line, we get large errors which leads to low accuracy and wrong predictions. The loss is the error in our predicted values of m and b. Our goal is try to minimize this error to obtain the most accurate value of m and b.                                                                                                                                            










Cost Function:

  • The different values for coefficients of lines( B꧐,B₁) gives different values of regression, and cost function is used to estimate the values of the coefficient for the best fit line.
  • It measures how linear regression model is performing.

Mean Absolute Error ( MA E ) :

A mean absolute error is a model evaluation metric used with regression models. 

Category

Actual values $

Predicted values $

2 – bed room

200 k

230 k

3 – bed room

300 k

290 k

4 – bed room

400 k

740 k

5 – bed room

500 k

450 k

  • Error = Actual price - Predicted price
  • Absolute Error = | Error | 
  • MAE =( Absolute Error1+ Absolute Error2+ Absolute Error N) / N 

MAE = ( 30 + 10 + 340 + 50 ) /4 = $ 107.5 K

Mean Squared Error ( MSE ):

We will use the Mean squared error function to calculate the loss. The process will be as follows

  1. Find the difference between the actual and predicted value 
  2. Square the difference
  3. Find the mean of the squares.



 


Comments