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.
这篇博客探讨了在机器学习中如何通过最小化平均平方误差来找到最佳的直线模型。内容展示了当θ1=1时,直线能完美通过所有数据点,使得成本函数J(θ0,θ1)为0。而当θ1=0.5时,数据点到直线的垂直距离增大,成本函数增加到0.58。因此,目标是找到使成本函数最小化的θ1值,即全局最小值。
227

被折叠的 条评论
为什么被折叠?



