How to find out best fitting line for Linear Regression

Data can't fit all the time in linear regression model. Need to find out the best fit line which has less error to the predicted value. Nothing but linear model should be having less error value to satisfy. That error called Loss function

Loss Function

A loss function is a way to map the performance of a model into a real number. It measures how well the model is performing its task, be it a linear regression model fitting the data to a line, a neural network correctly classifying an image of a character, etc. The loss function is particularly important in learning since it is what guides the update of the parameters so that the model can perform best.

Some of Squares of error in regression

From picture u can see the smallest distance to line. each distance call it as error.

error for each point (y1_pred - y1), (y2_pred - y2)...(yn_pred - yn)


Formula Some of Squares of error in regression
error caliculation
error(E) = 2.4/2 = 1.2

We have many more metrics available in the system to identify error. will see those in next