### 线性回归(Regression)
linear regression
logistic regression
softmax regression
#@author: gr
#@date: 2014-01-21
#@email: forgerui@gmail.com
一、linear regression
线性模型:
\]
代价函数:
代价函数使用平方误差损失函数。
\]
求解:
可以使用最小二乘法和梯度下降法。
最小二乘法:
\]
梯度下降法:
批梯度下降,增量梯度下降。更新参数,以使代价函数最小化。
二、logistic regression
逻辑回归模型:
输出 \(Y=1\) 的对数几率是由输入 \(x\) 的线性函数表示的模型,即logistic regression。
\]
\]
求事件的对数几率:
\]
对数几率是一个关于x的线性函数。
模型参数估计:
逻辑回归的参数估计可以采用极大似然估计求得。
$$\begin{align*}
l(\theta) = & \Pi_{i=1}^N (p_i)^{y_i}(1-p_i)^{1-y_i} \\
= & \sum_{i=1}^{N} [y_i\log{(p_i)} + (1-y_i)\log{(1 - p_i)}] \\
= & \sum_{i=1}^{N} [ y_i \log{(\dfrac{p_i}{1-p_i})} + \log{(1-p_i)}] \\
= & \sum_{i=1}^N [y_i(w \cdot x_i) - \log{(1 + e^{(w \cdot x )})}]
\end{align*}
$$
对\(L(w)\)求极大值,就可以得到\(w\)的估计值。用梯度下降法或拟牛顿法求解。
损失函数:
- Gold Standard
- Hinge Loss
SVM - Log Loss
Logistic Regression、Softmax Regression - Squared Loss
Linear Regression - Boosting
代价函数:
这里使用对数函数作为损失函数:
\]
用梯度下降法或拟牛顿法求解。
三、softmax regression
模型:
对于多分类问题,\(y_i \in \{ 1, 2, \cdots , k\}\)。对于其中一类作为positive,则另外的k-1类就为negative。
$$
\begin{align*}
h_\theta(x^{(i)})
= & \left[
\begin{array}{c}
p(y^{(i)} = 1 \mid x^{(i)}, \theta) \\
p(y^{(i)} = 2 \mid x^{(i)}, \theta) \\
\vdots \\
p(y^{(i)} = k \mid x^{(i)}, \theta) \\
\end{array}
\right] \\
= &
\dfrac{1}{\sum_{j=1}^k e^{\theta_j^Tx^{(i)}}}
\left[
\begin{array}{c}
e^{\theta_1^T x^{(i)}} \\
e^{\theta_2^T x^{(i)}} \\
\vdots \\
e^{\theta_k^T x^{(i)}} \\
\end{array}
\right]
\end{align*}
$$
用\(\theta\)将\(\theta_1,\theta_2, \ldots \theta_K\)罗列起来:
\begin{array}{c}
\theta_1^T \\
\theta_2^T \\
\vdots \\
\theta_k^T
\end{array}
\right]\]
得到softmax回归的代价函数:
\]
可以看出softmax是logistic的推广,同样用梯度下降法或拟牛顿法求解。
Reference
- http://www.cnblogs.com/bzjia-blog/p/3366780.html
- http://www.cnblogs.com/bzjia-blog/p/3370869.html
- 李航 著 《统计学习方法》
- http://blog.csdn.net/viewcode/article/details/8794401
- http://blog.csdn.net/abcjennifer/article/details/7716281
- Deva Ramanan 《Machine Learning》 Lecture1
### 线性回归(Regression)的更多相关文章
- 线性回归 Linear Regression
成本函数(cost function)也叫损失函数(loss function),用来定义模型与观测值的误差.模型预测的价格与训练集数据的差异称为残差(residuals)或训练误差(test err ...
- 线性回归、梯度下降(Linear Regression、Gradient Descent)
转载请注明出自BYRans博客:http://www.cnblogs.com/BYRans/ 实例 首先举个例子,假设我们有一个二手房交易记录的数据集,已知房屋面积.卧室数量和房屋的交易价格,如下表: ...
- Matlab实现线性回归和逻辑回归: Linear Regression & Logistic Regression
原文:http://blog.csdn.net/abcjennifer/article/details/7732417 本文为Maching Learning 栏目补充内容,为上几章中所提到单参数线性 ...
- Stanford机器学习---第二讲. 多变量线性回归 Linear Regression with multiple variable
原文:http://blog.csdn.net/abcjennifer/article/details/7700772 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回归 ...
- Sklearn库例子2:分类——线性回归分类(Line Regression )例子
线性回归:通过拟合线性模型的回归系数W =(w_1,…,w_p)来减少数据中观察到的结果和实际结果之间的残差平方和,并通过线性逼近进行预测. 从数学上讲,它解决了下面这个形式的问题: Lin ...
- 机器学习之多变量线性回归(Linear Regression with multiple variables)
1. Multiple features(多维特征) 在机器学习之单变量线性回归(Linear Regression with One Variable)我们提到过的线性回归中,我们只有一个单一特征量 ...
- 多元线性回归(Linear Regression with multiple variables)与最小二乘(least squat)
1.线性回归介绍 X指训练数据的feature,beta指待估计得参数. 详细见http://zh.wikipedia.org/wiki/%E4%B8%80%E8%88%AC%E7%BA%BF%E6% ...
- Locally weighted linear regression(局部加权线性回归)
(整理自AndrewNG的课件,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 前面几篇博客主要介绍了线性回归的学习算法,那么它有什么不足的地方么 ...
- Linear Regression(线性回归)(一)—LMS algorithm
(整理自AndrewNG的课件,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 1.问题的引出 先从一个简单的例子说起吧,房地产公司有一些关于Po ...
随机推荐
- Javascript注意事项四【提高循环性能的策略】
for(var i = item.length;i--){ process(item[i]); } 1.通过倒叙循环 2.最小化属性查询 3.尽量不要使用函数迭代(forEach)
- Fox-H 函数
1.定义 2.特例 3.在分数阶微分方程中的应用 4.如何画图
- 转发 Mongodb 和 Hbase的区别
原始网址:http://hi.baidu.com/i1see1you/item/783a701f39a87549e75e06ea 1.Mongodb bson文档型数据库,整个数据都存在磁盘中,hba ...
- UITableViewcell autolayout下动态高度
项目中最经常使用的一个UI就是UITableView了.iOS7.8进一步优化了复用机制,用起来相当爽.配合Autolayout,适配工作减轻了非常多. 曾经做适配工作都是在heightForRow里 ...
- HDU 5476 Explore Track of Point 数学平几
Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...
- 部署SharePoint解决方式包时遇到的问题
部署SharePoint解决方式包时遇到的问题 近期我在使用STSADM.EXE命令部署解决方式包的时候.遇到一个问题.很的难搞. 创建WSP文件非常easy.加入到解决方式库也非常e ...
- 解决Please ensure that adb is correctly located at 'D:\java\sdk\platform-tools\adb.exe' and can be executed.
遇到问题描述: 运行android程序控制台输出 [2012-07-18 16:18:26 - ] The connection to adb is down, and a severe error ...
- Custom-Progress-Dialog-Android
https://github.com/ManolescuSebastian/Custom-Progress-Dialog-Android
- 详解Android ActionBar之二:ActionBar添加Tabs标签和下拉导航
本节主要讲解ActionBar如何添加Tabs标签和下拉导航. 一.添加标签 Tabs 在ActionBar中实现标签页可以实现android.app.ActionBar.TabListener ,重 ...
- redis实现spring-redis-data的入门实例
redis的客户端实现.主要分为spring-redis-data .jredis. 记录下spring-redis-data的学习心得:spring-redis-data 中我目前主要用了它的存.取 ...