本文主要是介绍scikit-learn linearRegression 1.1.9 贝叶斯回归,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.1.9. 贝叶斯回归
可以在估计过程中使用贝叶斯回归技术包含正则化参数:正则化参数不是硬编码设置的而是手动调节适合数据的值
可以通过在模型的超参数上引入 uninformative priors
`Ridge Regression`_ 中 使用的正则化项等价于在一个参数为
且精度为
的高斯先验下寻找 一个最大的后验的解。而且并不是手动设置 lambda ,而是有可能把它看做一个随机变量来从从数据中估计。
为了获得一个完整的概率模型,输出 假设为关于
的高斯分布
Alpha 同样被看做是随机变量,需要从数据中来估计
贝叶斯回归的优势:
- 根据数据调节参数
- 在估计过程中包含正则化参数
贝叶斯回归劣势:
- 模型的推理比较耗时
References
- 关于贝叶斯方法一个非常好的说明可以参考 C. Bishop: Pattern Recognition and Machine learning (经典的PRML书籍)
- 而原始的算法在 Bayesian learning for neural networks by Radford M. Neal 中有详细描述。
1.1.9.1. 贝叶斯岭回归
BayesianRidge
对上述的回归问题估计了一个概率模型。先验参数 由下面的球形高斯给出:
先验参数 和
的选择满足 gamma distributions ,即高斯函数精度的共轭先验
生成的模型称为 Bayesian Ridge Regression ,和经典的 Ridge
类似。 参数 ,
以及
在模型的拟合中被共同估计。 其他的参数是
和
的gamma 先验的参数。(待校正) 这些通常被选择为 non-informative*(参考贝叶斯无信息先验)。参数统计通过最大化 *marginal log likelihood.
By default .

Bayesian Ridge Regression is used for regression:
After being fitted, the model can then be used to predict new values:
The weights of the model can be access:
由于贝叶斯框架,权重的发现同 普通最小二乘法 略有不同。然而Bayesian Ridge Regression 对于病态问题更具有鲁棒性。
Examples:
- Bayesian Ridge Regression
References
- More details can be found in the article Bayesian Interpolation by MacKay, David J. C.
1.1.9.2. Automatic Relevance Determination - ARD
ARDRegression
和 `Bayesian Ridge Regression`_ 非常相似,但是主要针对稀疏权重 [1] [2] 。
ARDRegression
提出一个不同于 的先验,通过弱化高斯分布为球形的假设。
相反, 的分布假设为一个平行轴的椭圆高斯分布。(同axis-alignen)
也就是说,每个权重 来自于一个中心在0点,精度为
的高斯分布:
with .
同 `Bayesian Ridge Regression`_ 形成对比, 每一维都有一个标准差
, 所有
的先验选择 和 由给定超参数
和
的gamma分布一样。

Bayesian Ridge Regression
Computes a Bayesian Ridge Regression on a synthetic dataset.
See 贝叶斯岭回归 for more information on the regressor.
Compared to the OLS (ordinary least squares) estimator, the coefficient weights are slightly shifted toward zeros, which stabilises them.
As the prior on the weights is a Gaussian prior, the histogram of the estimated weights is Gaussian.
The estimation of the model is done by iteratively maximizing the marginal log-likelihood of the observations.
Python source code: plot_bayesian_ridge.py
这篇关于scikit-learn linearRegression 1.1.9 贝叶斯回归的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!