Regression with Gradient Descent in Low-level Matlab
来源:互联网 发布:php读取网页源代码 编辑:程序博客网 时间:2024/06/05 06:22
from: http://www.csrdu.org/nauman/2010/06/25/regression-with-gradient-descent-in-low-level-matlab/
I just finished writing my first machine learning algorithm in Matlab. The algorithm is based on gradient descent search for estimating parameters of linear regression (but can be easily extended to quadratic or even higher-dimensional polynomials). It’s fairly easy if you know the theory behind the model. So, first a very brief theory portion. This isn’t a tutorial on statistics. Go read a book if you don’t know about regression.
Just to recall: Regression comes in when you want to estimate a response variable () given explanatory variables (). The goal for linear regression is to come up with values for parameters () such that you get a ‘best possible fit’ for each jth instance in the dataset of m instances:
In matrix notation, that comes simply to:
(For ease, we assume that is a vector of all 1s thus making the y-intercept).
The idea of gradient descent is to come up with the best (locally) values of . It does this by repeatedly updating the value of using the formula:
If you have no idea what this is or if you want to know this in-depth, read till the end.
Here’s the Matlab code for this whole procedure I wrote at first. Note the use of W for :
Then I figured that I was just doing loops and didn’t really need the matrices. So, I went back and thought about the whole nested loop thing and replaced the loop portion with this:
Seems suspiciously like the original formula, doesn’t it? Here’s what the plot look like. The red line shows the linear regression line calculated from a closed-form formula and the other lines show estimations of with the darkest colored ones being the initial guess and lighter ones are successive guesses.
And finally, as promised, here’s where you can learn all about this stuff: machine learning video lectures from Stanford.
- Regression with Gradient Descent in Low-level Matlab
- Regression gradient descent
- linear regression(4)-normal equation***compare with gradient descent
- 多变量线性回归中的批量梯度下降法(Batch Gradient Descent in Linear Regression with Multiple Variable)
- 2 Linear Regression, Gradient descent
- Liner Regression(Gradient descent algorithm)
- 回归(regression)、梯度下降(gradient descent)
- 回归(regression)、梯度下降(gradient descent)
- 回归(regression)、梯度下降(gradient descent)
- 回归(regression)、梯度下降(gradient descent)
- 回归(regression)、梯度下降(gradient descent)
- 回归(regression)、梯度下降(gradient descent)
- 回归(regression)、梯度下降(gradient descent)
- 回归(regression)、梯度下降(gradient descent)
- Linear regression and gradient descent algorithm
- linear regression(3)-Gradient Descent in Practice I/II(Feature Scalling/Learning Rate)
- Machine Learning in Gradient Descent
- Optimization Method -- Gradient Descent with Momentum Gradient Descent (转)
- DBA掌握的技术
- 64位ubuntu11.04上adobeair的安装以及webqq增强版(http://earneyzxl.blogspot.com/)
- Web Service是如何工作的
- 深入理解iPhone屏幕双缓冲技术
- stack interchange 发布了
- Regression with Gradient Descent in Low-level Matlab
- android socket 编程总结
- 初现
- 利用HttpHandler创建自定义后缀Rss源
- 头文件和.cpp 或.c 文件之间的关系
- 字节处理函数
- 从网上找到了一个 读取声音的程序
- linux我常用的命令
- 告别ASP.NET操作EXCEL的烦恼