美文网首页
【机器学习】-Week3 4. Cost Function

【机器学习】-Week3 4. Cost Function

作者: Kitty_风花 | 来源:发表于2019-11-30 10:51 被阅读0次

Cost Function

We cannot use the same cost function that we use for linear regression because the Logistic Function will cause the output to be wavy, causing many local optima. In other words, it will not be a convex function.

Instead, our cost function for logistic regression looks like:

When y = 1, we get the following plot for 

Similarly, when y = 0, we get the following plot for J(\theta)J(θ) vs h_\theta (x)hθ​(x):

If our correct answer 'y' is 0, then the cost function will be 0 if our hypothesis function also outputs 0. If our hypothesis approaches 1, then the cost function will approach infinity.

If our correct answer 'y' is 1, then the cost function will be 0 if our hypothesis function outputs 1. If our hypothesis approaches 0, then the cost function will approach infinity.

Note that writing the cost function in this way guarantees that J(θ) is convex for logistic regression.

来源:coursera 斯坦福 吴恩达 机器学习

相关文章

网友评论

      本文标题:【机器学习】-Week3 4. Cost Function

      本文链接:https://www.haomeiwen.com/subject/rmkkectx.html