成本函数-Intuition l

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 byhθ(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 ofJ(θ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=1is our global minimum.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,811评论 0 23
  • 我是带着问题来看的这本书。我对商业社会本身算是非常熟悉。我成长在一个商人家庭,在家里生意的动荡浮沉中度过了童年...
    霧切時雨Edge阅读 608评论 0 1
  • 文/静静 上周在教研室,偶尔看到周国平先生的《另一种存在》,匆匆翻了两页,便觉得是本好书,值得一看。 去图书馆借回...
    unique_安静阅读 1,651评论 4 21
  • 幸福到底是什么?许多人都会问自己,问别人。而每个人的理解又各自不同。 小时候,有父母的庇护,不懂得成人的世界。只要...
    冬妮娅阅读 343评论 0 0