一些问题:
1. 什么时候我的问题可以用GLM,什么时候我的问题不能用GLM?
2. GLM到底能给我们带来什么好处?
3. 如何评价GLM模型的好坏?
广义线性回归啊,虐了我快几个月了,还是没有彻底搞懂,看paper看代码的时候总是一脸懵逼。
大部分分布都能看作是指数族分布,广义差不多是这个意思,我们常见的线性回归和logistic回归都是广义线性回归的特例,可以由它推到出来。
参考:线性回归、logistic回归、广义线性模型——斯坦福CS229机器学习个人总结(一)
对着上面的教程,手写了一遍所有的公式,大致能理解其中的40%吧。
1. 线性回归和logistic回归都有概率形式,只是基础的分布假设不一样。线性回归假设误差y服从高斯分布;logistic回归假设y服从伯努利分布。有了分布形式,根据最大似然方法我们就很容易得到优化目标,这正好也推到出了我们用在线性回归中的最小二乘公式。
2. 在优化时所用的方法,梯度下降、梯度上升、牛顿法。梯度法的核心就是导数,我们优化的函数就是关于参数的函数,求导得斜率,走一步alpha,更新参数,迭代进行,即可得局部最优参数。
3. GLM的核心就是y服从的分布可以表示为指数分布族的形式,就可以推广线性模型的应用范围。logistic回归就是线性回归的推广。
那么如何根据指数分布族来构建广义线性模型呢?
啊哈,百度里讲GLM理论的不少(讲得也是比较粗糙),实例的几乎没有。下面是一个GLM在医学fMRI上的应用。
Statistical Analysis: The General Linear Model
What does a generalized linear model do? R
The overall summary is: You can first try linear regression. If this is not appropriate for your problem you can then try pre-transforming your y-data (a log-like or logit transform) and seeing if that fits better. However, if you transform your y-data you are using a new error model (in the transformed space such as log(y)-units instead of y-units, this can be better or can be worse depending on your situation). If this error model is not appropriate you can move on to a generalized linear model. However, the generalized linear model does not minimize square error in y-units but maximizes data likelihood under the chosen model. The distinction is mostly technical and maximum likelihood is often a good objective (so you should be willing to give up your original square-loss objective). If you wan’t to go further still you can try a generalized additive model which in addition to re-shaping the y distribution uses splines to learn r