线性回归模型

x1,x2...是我们所选取的特征,h(x)是我们所建立的模型,其中有n+1个参数。令x0=1,则


损失函数

作为损失函数,我们的目的是使得上式最小。
梯度下降

对参数进行赋值,使得损失函数按梯度下降最快的方向进行,一直迭代下去,最终得到局部最小值。α是学习率,决定了沿梯度下降的方向迈出的步子有多大。

图中红点的导数,即该点的斜率为正斜率,参数值向左移动,就要减去该参数的导数。


正规方程
正规方程通过求解下面的方程来找出使得损失函数最小的参数:

利用正规方程解出向量:

推导过程:


网友评论