Cost Function - Coursera
Cost Function - Coursera
Cost Function
We can measure the accuracy of our hypothesis function by using a cost function. This
takes an average di erence (actually a fancier version of an average) of all the results of the
hypothesis with inputs from x's and the actual output y's.
m m
2
1 1 2
^
J( 0 , 1 ) = yi yi = (h (xi ) y i )
2m ( )
2m
i=1 i=1
To break it apart, it is 1
2
x where x is the mean of the squares of h (xi ) yi , or the
di erence between the predicted value and the actual value.
This function is otherwise called the "Squared error function", or "Mean squared error".
The mean is halved ( 12 ) as a convenience for the computation of the gradient descent, as
the derivative term of the square function will cancel out the 1
2
term. The following image
summarizes what the cost function does:
https://www.coursera.org/learn/machine-learning/supplement/nhzyF/cost-function 1/2