zoukankan      html  css  js  c++  java
  • [ML] 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.

    Cost Function - Intuition I

    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.

    Our 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. In such a case, the value of J(θ0,θ1) will be 0. The following example shows the ideal situation where we have a cost function of 0.

    When θ1=1, we get a slope of 1 which goes through every single data point in our model. Conversely, when θ1=0.5, we see the vertical distance from our fit to the data points increase.

    This increases our cost function to 0.58. Plotting several other points yields to the following graph:

    Thus as a goal, we should try to minimize the cost function. In this case, θ1=1 is our global minimum.

    J(θ1) is th slope of h(x)

  • 相关阅读:
    11 [异常]-try...except
    3-4 网络编程 练习题
    31 选课系统
    3-3 面向对象 本章总结
    3-2 面向对象中级练习题
    3-1 面向对象练习题
    11 [面向对象]-面向对象的软件开发
    10 [面向对象]-元类
    App集成极光推送开发流程[关键步骤]
    App集成极光推送步骤
  • 原文地址:https://www.cnblogs.com/Answer1215/p/13488385.html
Copyright © 2011-2022 走看看