Regression(2)-------- Linear Regression with one variable
来源:互联网 发布:杨振宁 丘成桐 知乎 编辑:程序博客网 时间:2024/06/07 02:36
单参数线性回归 Linear Regression with one variable
(一)、Cost Function
线性回归是给出一系列点假设拟合直线为h(x)=theta0+theta1*x, 记Cost Function为J(theta0,theta1)
之所以说单参数是因为只有一个变量x,即影响回归参数θ1,θ0的是一维变量,或者说输入变量只有一维属性。
下图中为简化模式,只有theta1没有theta0的情况,即拟合直线为h(x)=theta1*x
左图为给定theta1时的直线和数据点×
右图为不同theta1下的cost function J(theta1)
cost function plot:
当存在两个参数theta0和theta1时,cost function是一个三维函数,这种样子的图像叫bowl-shape function
将上图中的cost function在二维上用不同颜色的等高线映射为如下右图,可得在左图中给定一个(theta0,theta1)时又图中显示的cost function.
我们的目的是最小化cost function,即上图中最后一幅图,theta0=450,theta1=0.12的情况。
(二)、Gradient descent
gradient descent是指梯度下降,为的是将cost funciton 描绘出之后,让参数沿着梯度下降的方向走,并迭代地不断减小J(theta0,theta1),即稳态。
每次沿着梯度下降的方向:
参数的变换公式:其中标出了梯度(蓝框内)和学习率(α):
gradient即J在该点的切线斜率slope,tanβ。下图所示分别为slope(gradient)为正和负的情况:
同时更新theta0和theta1,左边为正解:
关于学习率:
α太小:学习很慢; α太大:容易过学习
所以如果陷入局部极小,则slope=0,不会向左右变换
本图表示:无需逐渐减小α,就可以使下降幅度逐渐减小(因为梯度逐渐减小):
求导后:
由此我们得到:
其中x(i)表示输入数据x中的第i组数据
- Regression(2)-------- Linear Regression with one variable
- 2-Linear Regression with One Variable
- (1)Linear Regression with One Variable
- (1)Linear Regression with One Variable
- Linear regression with one variable
- Linear Regression with One Variable
- Linear regression with one variable
- Machine Learning:Linear Regression With One Variable
- Machine Learning - Linear Regression with One Variable
- 第二周- -Linear Regression with one variable
- 机器学习-Linear Regression with One Variable
- Coursera《machine learning》--(2)单变量线性回归(Linear Regression with One Variable)
- Stanford机器学习---第一讲. Linear Regression with one variable
- Stanford ML - Lecture 1 - Linear regression with one variable
- Stanford机器学习---第一讲. Linear Regression with one variable
- Stanford机器学习---第一讲. Linear Regression with one variable
- 第一章-------单参数线性回归 Linear Regression with one variable
- Stanford机器学习---第一讲. Linear Regression with one variable
- 滞韩志愿军英烈遗骸即将走上回家之路罗援新浪博客
- Java中对象与引用的理解
- The basic knowledge of deep learning
- libzbar扫描二维码因自带有打开闪光灯的方法,若在touch上运行此时没有闪光灯若想有提示
- 用微信公众号怎么做一个人面识别技术呢?
- Regression(2)-------- Linear Regression with one variable
- 设置图片等比例缩小
- 给图片加水印
- 漫谈数据库索引
- STM32基于库函数版本的系统工作频率与CAN工作波特率设置
- Lock-Free?还是多入口?
- 第一篇博文
- zedboard--我回来了
- 菲波那契数列 C 递推方法