是跟随吴恩达机器学习课程学习的,具体的推导过程不再给出
求Cost Function:
假设函数 h ( x ) = θ 0 + θ 1 x \displaystyle h(x) = \theta_0 + \theta_1 x h(x)=θ0+θ1x,样本数为 n n n,特征值数为 1 1 1,cost function为
J ( θ 0 , θ 1 ) = 1 2 n ∑ i = 1 n ( h ( x i ) − y i ) 2 \displaystyle J(\theta_0, \theta_1) = \frac{1}{2n}\sum^n_{i = 1}(h(x_i) - y_i)^2 J(θ0,θ1)=