cost function

Why ?

Where ?

How ?

What ?

root mean squared error or mean squared error.

get the best possible regression line

cost function formula

Machine learning

Cost function is the calculation of the error between predicted values and actual values, represented as a single real number.


The cost function is the average error of n-samples in the data (for the whole training data)

We can measure the accuracy of our regression model by using a cost function.

images
To break it apart, it is 1/2 * MSE where MSE is the mean of the squares of hθ(xi) - yi, or the difference between the predicted value and the actual value.

graphicly

If we try to think of it in visual terms, our training data set is scattered on the x-y plane. We are trying to make a straight line (defined by hθ(x)) which passes through these scattered data points.

objective

the objective is to get the best possible line. The best possible line will be such so that the average squared vertical distances of the scattered points from the line will be the least. Ideally, the line should pass through all the points of our training data set.

results

we need to minimizes the cost function as much as possible to get the best θ1 & θ2 we can get for our regression equation