[Machine Learning]吴恩达机器学习笔记 二 ——单变量线性回归

1.Model description 模型描述

In Supervised Learning, we have a data set called a training set(训练集), 

了解需要使用的符号:define lots of symbols

how work?

Training Set 提供训练集,

Learning Algorithm,learning from training set and output a function

h,hypothesis function 假设函数 (conventionly denoted by lowercase h, the standard terminology标准术语 ), it leads attributes(values we set or know) to getting the estimated values.

linear regression model 线性回归模型,start with fitting the linear funvtions, on the base of it, we eventually have more complex models and learning algorithms.

 

2.Cost function 代价函数

cost function is also called the sequared error function(平方误差函数),or square error cost function(平方误差代价函数)

it is probably the most commonly used one for regression problems.

代价函数的目的是通过parameter来获取最小的这个parameter的函数,which is the object function for the linear regression.

这个parameter 能够是hypothesis function 最优。

 

3.Gradient descent algorithm 梯度下降算法

for minimizing the cost function

步骤:先初始化参数,然后不断调整参数来减小代价函数,直到达到预期最小为止

梯度下降算法适用于很多函数,这个以最小化代价函数为例。下面是一个例子

需要注意的是,同时更新theta0和theta1

推导:

以上图为例,推导梯度下降算法。

α为learning rate 为非负,α越小,梯度下降越慢。α太大,梯度下降可能会越过最低点,导致无法收敛或发散,离最优点越来越远。

当偏导数为正时,θ应向左移动,并不断更新。

当偏导数为负数时, α前的 - 号,会使θ变大,因此向右不断更新。

当梯度下降达到局部最优时,不会再改变参数值,使得始终保持局部最优点。

梯度下降可以使用一个固定的learning rate α,当接近局部最低点时,导数值会越来越小,接近0,因此梯度下降的速度会自动变慢,因此不需要调整α的大小。

3.Gradient descent for linear regression 线性回归的梯度下降

 

cost function for linear regression is always going to be a bow-shaped function, which is called convex function(凸函数)

convex function doesn't have any local optima, except for one global optimum.凸函数只有一个全局最优。

 

Batch Gradient Descent

Batch: each step of gradient descent uses all the training examples.

每一步梯度下降,都遍历整个训练样本(指的是所有求得的数据求和)。

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值