Regression:Logistic Regression Analysis
Linear Regression在处理数据输入和数据输出的线性关系上非常有用,但是还是有很多情况,如数据输出空间为R且连续,如果处理的数据离散、输出为二分类(Binary,{0,1})时,LR就不合适处理这宗数据模型,准确的说不是最优(Optimal)处理数据的方法。在这种数据模型下,Logistic Regression(LR)方法作为一种替代的Regression方法正好能够处理这些数据模型。
注意:LR从名字上看是Regression,实际上是分类算法;本文讨论的是Binomial二分数据,如Success or Fail,death or live,malignant or benign等。
在Logistic Regression中,使用更多的是Odds而非Proportions;前者定义的是输出空间中两个输出变量的比值。如果P定义为Positive的概率,1-P表示为Negative的概率,那么Odds的概率定义为:
Odds的定义是结果集中Positive和Negative的比例。
在Linear Regression中,输出值为线性函数,所以输出的空间为(-Infinate,+Infinate),在Logistic Regression中,Positive概率的输出范围为[0,1],需要映射这种关系,从[0,1]映射到[-Infinate,+Infinate],引入logit函数能够满足这种映射关系:
Logit函数的数学意义大家可以仔细思考下,是怎么完成这种映射关系的。
我们使用logit函数进行建模,能够使输出空间为(-Infinate,+Infinate),而Linear Regression的输出空间也为(-Infinate,+Infinate),那么我们使用logit来按照Linear Regression的思路建模:
将Odds概念和logit函数的概念放到一起,可以得到:
其中P表示positive的概率,将P解出来,可以得到:
将其中的函数部分重新定义出来:
该函数被称为是Logistic Function、或者是Sigmoid Function,从wiki上的一张截图看下Sigmoid函数的性质:
前面的推导比较清楚地描述了为什么使用Sigmoid函数作为Logistic Regression的一部分。我看到其他人在分析Logistic Regression时,只是简单的将Sigmoid函数提出来作为结果的一部分,如果想了解Sigmoid函数在Logistic Regression中的推导,请再仔细看下上面的推导过程。
我们了解了Sigmoid函数在Logistic Regression中的地位后,我们继续来看Logistic Regression的分类问题。假设模型服从Bernoulli分布:
考虑使用二分类(Binomial)来建模,多分类的问题也可以转化为二分类问题来解决。假设类别标签分别为C1,C2表示,则C1后验概率可以表示为:
其中Sigmoid函数的定义如上所示。
根据概率的性质,C2的概率值可以根据C1计算为:
可以看出来,后验概率为服从Bernoulli分布的离散分布,这个跟前面的Linear Regression模型有很大的不同。前面目标值连续,使用高斯分布模型;后者目标值离散,使用Bernoulli分布来计算。
下面我们计算独立Logistic Regression的Maximum Likelihood Estimation(MLE)。假设训练集合为{X,y},其中t为{0,1}集合中;假定N个观察变量符合i.i.d.分布,则似然函数可以表示为:
从上面的MLE定义可以看出来,这个最大似然估计和Linear Regression的分析一致;可以作为最大似然的函数的相反数,得到如下表示:
这个误差结果被称为是Cross-Entropy Error Function,这个就是Logistic Regression要优化的目标函数。下面的工作就是优化、求解这个误差函数。
Cross-Entropy Error Function
优化该误差函数可以使用前面提到的Gradient Descent算法。在梯度下降算法中,梯度的结算至为关键,计算过程如下:
然后根据Linear Regression模型里面的梯度下降方法进行迭代求解:
Cross-Entropy Error Function高级优化算法
我们使用Gradient Descent算法来求解的话,对于学习率的计算是个难题:如果学习率过大,导致收敛不能保证;学习率过小的话,导致收敛速度太慢。而一些比较复杂的优化算法能够避免学习率的缺点。当然这些算法和随机梯度相比会更加复杂,不过收敛速度也比较快。
在Andrew Ng的机器学习课程中,除去梯度下降(Gradient Descent)外,还提到另外三种优化算法:
Conjugate Gradient:http://class.htu.cn/nla/chat5/sect5_2.htm,重点在于选择共轭方向作为搜索方向,直到算法收敛。
BFGS:http://en.wikipedia.org/wiki/BFGS_method
L-BFGS:http://en.wikipedia.org/wiki/Limited-memory_BFGS
这几个算法都是优化算法中比较典型的算法。大家如果想深入理解的话,可以仔细看下后面的wiki链接。
本次Logistic Regression结束。
相关推荐
Applied Logistic Regression Analysis, (2nd Edition) Scott Menard 有些图不是很清楚
The main purpose of this presentation though is to show the reader how ...logistic regression model which is designed for these types of variables see Chapter 13 ">The main purpose of this presentation ...
CONTENTS 1 Introduction 2 Simple Linear Regression 3 Multiple Linear Regression 4 Regression Diagnostics: Detection of Model Violations 5 Qualitative Variables ...12 Logistic Regression 13 Further Topics
一、回归分析(Regression Analysis)定义与分类 回归分析(Regression Analysis)是一种统计学上分析数据的方法,目的在于了解两个或多个变量间是否相关、相关方向与强度,并建立数学模型以便观察特定变量来预测...
Gradient Boosting, Random Forest, Logistic Regression, Neural Networks, RBF Networks, Maximum Entropy Classifier, KNN, Naïve Bayesian, Fisher/Linear/Quadratic/Regularized Discriminant Analysis. ...
Logistic Regression; Multivariate Analysis of Variance (MANOVA) and Discriminant Analysis; Principal Components Analysis; Exploratory Factor Analysis; and Non-Parametric Tests. This helpful resource ...
This book shows the use of R in specific cases such as one-way ANOVA analysis, linear and logistic regression, data visualization, parallel processing, bootstrapping, and more. It takes a hands-on, ...
bayesian textbooks- t-tests, analysis of variance (ANOVA) and comparisons in ANOVA, multiple regression, and chi-square (contingency table analysis). Coverage of experiment planning R and BUGS ...
5 Logistic regression 6 Support vector machines 7 Improving classification with a meta-algorithm: Adaboost Part 2: Forecasting numeric values with regression 8 Predicting numeric values: regression 9 ...
Readers will find a unified generalized linear models approach that connects logistic regression and Poisson and negative binomial regression for discrete data with normal regression for continuous ...
Readers will find a unified generalized linear models approach that connects logistic regression and Poisson and negative binomial regression for discrete data with normal regression for continuous ...
Chapter 3: Logistic Regression and Discriminant Analysis Chapter 4: Advanced Feature Selection in Linear Models Chapter 5: More Classification Techniques – K-Nearest Neighbors and Support Vector ...
线性回归餐厅情感分析目录表描述线性回归机器学习模型可预测评论是肯定的还是否定的。 它以86%的准确度正确预测正确的标签。...运行代码将以下内容添加到类文件中: x = logistic_regression("train_d
You will learn how to use SAS to perform analytics and model using both basic and advanced techniques like multiple regression, logistic regression, and time series analysis, among other topics....
Appendix A: Statistical Methodology for Dichotomous Logistic Regression . . . 239 Chapter 9. Logistic Regression II: Polytomous Response 241 9.1 Introduction . . . . . . . . . . . . . . . . . . . . . ...
regression analysis、聚类分析 Cluster analysis、决策树 decision tree、逻辑回归 logistic regression、模拟退火 simulated annealing、排队论 queuing theory、神经网络 neural networks、时间序列 ARMA、因子...
are linear regression, logistic regression, Poisson regression, survival analysis, and analysis of variance. Each topic is covered in two chapters: one introduces the topic with simple univariate ...
Master popular machine learning models including k-nearest neighbors, random forests, logistic regression, k-means, naive Bayes, and artificial neural networks Learn how to build and evaluate ...
Readers will find a unified generalized linear models approach that connects logistic regression and Poisson and negative binomial loglinear models for discrete data with normal regression for ...
Classification techniques, to predict a qualitative outcome value using logistic regression, discriminant analysis, naive bayes classifier and support vector machines. Advanced machine learning ...