机器学习笔记之代价函数

来源:互联网 发布:linux怎么用vi创建文件 编辑:程序博客网 时间:2024/05/21 11:34

Cost Function

We can measure the accuracy of our hypothesis function by using a cost function. This takes an average difference (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.

J(θ0,θ1)=12mi=1m(y^iyi)2=12mi=1m(hθ(xi)yi)2

To break it apart, it is 12 x¯ where x¯ is the mean of the squares of hθ(xi)yi , or the difference 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 12 term. The following image summarizes what the cost function does:


原创粉丝点击