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 ) h_\theta(x) 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 ) J(\theta_0, \theta_1) J(θ0,θ1) will be 0. The following example shows the ideal situation where we have a cost function of 0.

在这里插入图片描述

When θ 1 = 1 \theta_1 = 1 θ1=1, we get a slope of 1 which goes through every single data point in our model. Conversely, when θ 1 = 0.5 \theta_1 = 0.5 θ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 \theta_1 = 1 θ1=1 is our global minimum.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值