【Machine Learning】笔记:Logistic Regression Model
来源:互联网 发布:淘宝清库存 编辑:程序博客网 时间:2024/04/29 15:34
课程是 Coursera 上 Andrew Ng 的公开课 Machine Learning 第三周的内容之一。
Hypothesis Representation
在 logistic regression 中,定义 hypothesis 为:
其中,
本质上,就是
Cost Function
在 Linear Regression 中,定义误差函数为:
把里面的
可以把
但是,当
因此,重新定义 logistic regression 的 cost function 为:
再次运用 Gradient Descent
先把
如果写成向量化的形式:
使用梯度下降法更新:
在向量化形式下:
其他最优化方法
在最小化
- Conjugate gradient 共轭梯度法
- BFGS 变尺度法
- L-BFGS
在使用它们时,要求定义出下面两项的计算方法:
J(θ) ∂∂θjJ(θ)for j=0,1,…,n
这些高级的算法相比于梯度下降法,可以不用人为地选择学习速率
Octave 最优化方法示例
下面举一个在 Octave 中使用最优化函数的例子。
先定义一个 costFunction 函数,返回值是
function [jVal, gradient] = costFunction(theta) jVal = [...code to compute J(theta)...]; gradient = [...code to compute derivative of J(theta)...];end
然后我们就可以调用 Octave 自带的无约束最小化函数 fminunc:
options = optimset('GradObj', 'on', 'MaxIter', 100);initialTheta = zeros(2,1);[optTheta, functionVal, exitFlag] = fminunc(@costFunction, initialTheta, options);
上面的代码中,先用 options 存储一些设置参数,第一个是设置梯度目标函数的状态为“打开”,这意味着需要提供一个梯度,第二个是指最大迭代次数为100次。
之后将事先定义好的 costFunction 传入 fminunc 函数中,@
表示传入函数的指针。
fminunc 的返回值有三个:参数的最优解,最优的函数值,退出的状态(1表示收敛)。
- 【Machine Learning】笔记:Logistic Regression Model
- Machine Learning:Logistic Regression
- [Machine Learning]--Logistic Regression
- Machine Learning--logistic regression
- Machine Learning:Logistic Regression
- Machine Learning Notes - Logistic Regression
- Machine Learning - Regularized Logistic Regression
- machine learning之logistic regression
- Stanford Machine Learning 公开课笔记(2) Logistic Regression
- [笔记]机器学习(Machine Learning) - 02.逻辑回归(Logistic Regression)
- #“Machine Learning”(Andrew Ng)#Week 3_2:Logistic Regression Model
- 转 machine learning 之logistic regression
- 【Machine Learning】逻辑回归 Logistic Regression
- Coursera Machine Learning Week 3.1: Logistic Regression
- Machine Learning—Classification and logistic regression
- Machine Learning week 3 quiz : Logistic Regression
- Machine Learning - Logistic Regression - Two-class Classification
- Machine Learning - Logistic Regression - Multi-class Classification
- 人生第一篇博客,写在这里
- CSU
- 2017 Multi-University Training Contest
- A
- python高阶函数中的map、filter、reduce
- 【Machine Learning】笔记:Logistic Regression Model
- html编辑器
- 百度鹰眼地图使用
- OpenGL ES/Open CV/OpenGL、OpenCL与OpenAL研究
- Android性能优化之布局优化(一)
- 开发中常用的app神器
- 数据结构——三
- HDU6053(72/600)
- Java常用类及其方法(一)Object