机器学习(二)

一、模型
线性回归
在这里插入图片描述
in supervised learning,have a data set(called a training set)-> to predict the price of the house

symbols of supervised learning:
m ->训练样本的数量
x ->输入变量(feature)
y->目标变量
在这里插入图片描述
在这里插入图片描述
二、代价函数
在这里插入图片描述
what we want to do is come up with values for parameter
(minimization problem)->minimize the square difference
(h(x)-y) ->sum over my training set,sum from i equals 1 to M of the square difference between the prediction

在这里插入图片描述
in actually,cost function:
在这里插入图片描述
在这里插入图片描述
depend on your training set,get a cost function looks like that:
在这里插入图片描述
使用等高线:
在这里插入图片描述
三、梯度下降

  • start with some parameters
  • keep changing to reduce cost function until end up at a minimum
    可能由于初始点的不同,导致最后结果的差异:
    在这里插入图片描述
    在这里插入图片描述
    learning rate:how big a step we take downhill with gradient descent
  • if too small,gradient descent can be slow
  • if too large,gradient descent can overshot the minimum,it may fail to converge,or even diverge
  • as we approach a local minimum,gradient descent will automatically take small steps,so,no need to decrease learning rate over time

在这里插入图片描述
需要先更新temp后,再赋值,否则temp1是按照更新后的值进行计算所得到的。

simplified situation:
在这里插入图片描述
在这里插入图片描述
Batch” Gradient Descent:each step of gradient descent uses all the training examples.

some other of gradient descent that are not batch versions,look at small subsets of the training sets at a time.

在这里插入图片描述
在这里插入图片描述
四、多元特征变量
在这里插入图片描述
多个特征量表达式可以写为;
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
五、多元梯度下降(特征缩放)
idea:make sure features are on a similar scale
在这里插入图片描述
it turns out gradient descent will just have a much harder time(反复振荡)

特征值除以最大值:
在这里插入图片描述
get every feature into approximately (-1,1)

归一化:
在这里插入图片描述
即(x-average value)/(range value)

六、多元梯度下降法(学习率)

  • debugging:how to make sure gradient descent is working correctly(cost function decrease after every iteration)
    在这里插入图片描述
  • how to choose learning rate(for sufficiently small learning rate,cost function decrease on every iteration)

除了线性回归,还可以使用多项式回归等其他拟合方法

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值