假设函数
h θ ( x ) = θ 0 + θ 1 x 1 + θ 2 x 2 + θ 3 x 3 + . . . + θ n x n h_\theta(x) = \theta_0+ \theta_1x_1 + \theta_2x_2 + \theta_3x_3 + ...+ \theta_nx_n hθ(x)=θ0+θ1x1+θ2x2+θ3x3+...+θnxn
引入 x 0 = 1 x_0 =1 x0=1, h θ ( x ) = θ 0 + θ 1 x 1 + θ 2 x 2 + θ 3 x 3 + . . . + θ n x n h_\theta(x) = \theta_0+ \theta_1x_1 + \theta_2x_2 + \theta_3x_3 + ...+ \theta_nx_n hθ(x)=θ0+θ1x1+θ2x2+θ3x3+...+θnxn
转换成向量形式
h θ = θ T X h_\theta=\theta^TX hθ=θTX
损失函数(代价函数)
J ( θ 0 , θ 1 , . . . , θ n ) = 1 2 m ∑ i = 1 m ( h θ ( x ( i ) ) − y ( i ) )