《Parameter estimation for text analysis》阅读笔记(二)

本文内容为Parameter estimation for text analysis阅读笔记第二篇,如有不对之处,恳请各位批评指正!

简介:

Parameter estimation for text analysis的第二部分所讲内容为“Parameter estimation approaches”,主要介绍了三种参数估计方法:Maximum likelihood (ML),Maximum a posteriori (MAP)和Bayesian inference。

这一部分所要解决问题是2个inference problems:

(1)Estimation problem:找一个distribution的一组参数,使得这组参数下的这个distribution可以最fit观测数据\chi

(2)Prediction/Regression problem:在给定一组观测值\chi的基础之上,计算得到出现新数据\widetilde{x}的概率p(\widetilde{x}|\mathcal{X})

 \mathcal{X} \stackrel{\Delta}{=} \{ x_i\}^{|\mathcal{X}|}_{i=1}, 其中一系列的x_i是关于随机变量X的独立同分布的实现(realisation)。

此处我们给出Bayes's rule,并以该公式为基础引入我们即将要介绍的3类方法:

  \LARGE $$p(\vartheta|\mathcal{X})=\frac{p(\mathcal{X}|\vartheta)p(\vartheta)}{p(\mathcal{X})}$$

以上公式中各个部分的名称如下:

\LARGE $$posterior=\frac{likelihood\cdot prior}{evidence}$$                       

在介绍下面的方法之前,在此首先需要强调:我们的目标是什么?我们的目标是,在given \chi下,我们得到新数据\widetilde{x} 的概率有多大?即:

\LARGE p(\widetilde{x}|\mathcal{X})=\int_{\vartheta\in\Theta}p(\widetilde{x}|\vartheta)\ p(\vartheta|\mathcal{X})d\vartheta

于是以下的方法都围绕着这个目标式子展开。                   

1. 极大似然估计(Maximum Likelihood Estimation)

似然函数公式如下所示:

 \LARGE \mathcal{L}(\vartheta|\mathcal{X}) \triangleq p(\mathcal{X}|\vartheta)=\bigcap_{x\in\mathcal{X}}\{X=x|\vartheta\}=\prod_{x\in\mathcal{X}}p(x|\vartheta)                                               

其中值得注意的是,在似然函数中,采用的公式虽然是以\vartheta参数为条件下\chi (观测数据)的概率,但它的“变量”实际上是参数\theta,而\chi是事先given出来的(因为我们要进行参数估计)。我们可以从上式最左侧中条件和自变量的设定看出。

但由于对数似然函数(log likelihood)是一个比一般似然函数更易于处理的形式,我们一般对似然函数表示如下:

 \LARGE \widetilde{\vartheta}_{\text{ML}}=\underset{\mathcal{\vartheta}}{argmax}\mathcal{L}({\mathcal{\vartheta}}|\mathcal{X})=\underset{\mathcal{\vartheta}}{argmax}\sum_{x\in\mathcal{X}}p(\mathcal{X}|\mathcal{\vartheta})                                       

此时可以对参数的每一维度求导并令导数为0,从而进行参数估计:

\LARGE \frac{\partial \mathcal{L}(\vartheta|\mathcal{X})}{\partial \vartheta_k}\stackrel{!}{=}0\ \ \ \ \ \forall \vartheta_k\in\vartheta                                                           

对数据所服从的参数\vartheta进行估计之后,我们就可以对在已知观测数据\chi下某一个新数据\widetilde{x}出现的概率进行估计:

 \LARGE p(\widetilde{x}|\mathcal{X})\\ =\int_{\vartheta\in\Theta}p(\widetilde{x}|\vartheta)p(\vartheta|\mathcal{X})d\vartheta\\ \approx\int_{\vartheta\in\Theta}p(\widetilde{x}|\vartheta_{\text{ML}})p(\vartheta|\mathcal{X})d\vartheta=p(\widetilde{x}|\hat{\vartheta}_{\text{ML}})                                                     

可能会有人有疑问:为什么我们能将被积函数里第一个p中given的\vartheta替换成\vartheta_{\text{ML}}, 而第2个p中的就不行呢?

原因是,首先我们要明确,这里的替换是一种对于该积分的“近似计算”。我们通过fix住p(\widetilde{x}|\vartheta)的方式,使得我们只需要积分p(\vartheta|\mathcal{X})就够了。而又由于p(\vartheta|\mathcal{X})\vartheta下的积分为1,所以直接消去,因而我们所要求的:(在已知观测值下某一个新数据出现的概率)p(\widetilde{x}|\mathcal{X}) 就可以由极大似然函数下估计出来的参数\vartheta,代入likelihood函数 p(\widetilde{x}|\vartheta) 进行计算,并用该值进行估计。

又有人可能这么问:这样的估计准确吗?毕竟p(\widetilde{x}|\vartheta)也是要随着\vartheta而改变的呀?没错,p(\widetilde{x}|\vartheta)是会改变,但我们同时也要注意到,对于每一个p(\widetilde{x}|\vartheta),其对应着一个p(\vartheta|\mathcal{X}),我们可以把这个p(\vartheta|\mathcal{X})当作权重,而在ML估计下,这个权重是较大的,所以该权重下的p(\widetilde{x}|\vartheta)比较具有代表性,那么自然就可以作为整个积分的估计值。

或者换句话讲,对于该积分的计算就像是在p(\vartheta|\mathcal{X})下计算p(\widetilde{x}|\vartheta)的均值,也即E_{p(\vartheta)|\mathcal{X}}[p(\widetilde{x}|\vartheta)],我们用p(\vartheta|\mathcal{X})较大的一点的p(\widetilde{x}|\vartheta),来代替这个均值,自然是一个较好的估计。

例子:(原文中的例子对于后文都是有一定的铺垫意义)

对于一个掷不规则硬币的实验,我们可以把这个实验当作Bernoulli experiment。假设我们将该实验做N次,其中随机变量为C,当C=1时,意味着硬币正面朝上,当C=0时,意味着硬币背面朝上。硬币正面朝上的概率p是未知的。我们的目的是估计这个p值。

当我们做一次实验时,有:

\LARGE p(C=c|p)=p^c\ (1-p)^{1-c}\triangleq Bern(c|p)

我们可以采用ML的estimator,对参数p进行估计:

\LARGE \mathcal{L}\\ =log \prod_{i=1}^N\ p(C=c_i|p)=\sum_{i=1}^N log\ p(C=c_i|p)\\ =n^{(1)}log\ p(C=1|p)+n^{(0)}log\ p(C=0|p)\\ =n^{(1)}log\ p+n^{(0)}log\ (1-p)

对参数p求导并令导数为0有:

\LARGE \frac{\partial \mathcal{L}}{\partial p}=\frac{n^{(1)}}{p}-\frac{n^{(0)}}{1-p} \stackrel{!}{=}0

解得:

\LARGE \hat{p}_{ML}=\frac{n^{(1)}}{n^{(1)}+n^{(0)}}=\frac{n^{(1)}}{N}

可见,在ML估计下,硬币正面朝上的概率是通过统计历史数据中正面朝上的次数占总实验次数的比例而得到的。

2. 极大后验概率估计(Maximum a Posteriori estimation)

极大后验概率的方法与极大似然估计方法类似,但与极大似然估计方法不同的是,极大后验概率的方法在原方法的基础之上加上了一个priori belief。该方法的参数估计公式如下:

\LARGE \LARGE \widetilde{\vartheta}_{\text{MAP}}=\underset{\mathcal{\vartheta}}{argmax}\ p({\mathcal{\vartheta}}|\mathcal{X})                                                        

利用上文所述的Bayes' rule, 我们可以进行如下推导:

\LARGE \widetilde{\vartheta}_{\text{MAP}}\\ =\underset{\mathcal{\vartheta}}{argmax}\ p({\mathcal{\vartheta}}|\mathcal{X})\\ =\underset{\mathcal{\vartheta}}{argmax}\ \frac{p(\mathcal{X}|\vartheta)p(\vartheta)}{p(\mathcal{X})}\\ =\underset{\mathcal{\vartheta}}{argmax}\ p(\mathcal{X}|\vartheta)p(\vartheta)\\ =\underset{\mathcal{\vartheta}}{argmax}\ \{\mathcal{L}(\vartheta|\mathcal{X})+log\ p(\vartheta)\}\\ =\underset{\mathcal{\vartheta}}{argmax}\ \{\sum_{x\in\mathcal{X}}log\ p(x|\vartheta)+log\ p(\vartheta)\}                                                                      

与极大似然估计中参数估计的式子相比,极大后验概率式中加入了一个 log\ p(\vartheta) 项,该项可被用于加入额外的知识或是防止过拟合的出现(强制令该公式偏好于简单的模型)。

对于这个关于\vartheta 的分布p(\vartheta),我们应该如何去估计呢?其实我们可以采用p(\vartheta) := p(\vartheta|\alpha), 将参数\vartheta 也置于概率的框架下,从而得到一个层次化的参数分布,这种层次化参数分布同样也解释了为何参数\alpha被称为hyperparameter。

在得到MAP下估计的\vartheta 参数后,我们同样可以得到p(\widetilde{x}|\mathcal{X}) 的估计:

\LARGE p(\widetilde{x}|\mathcal{X})\approx\int_{\vartheta\in\Theta}\ p(\widetilde{x}|\widetilde{\vartheta}_{\text{MAP}})p(\vartheta|\mathcal{X})d\vartheta=p(\widetilde{x}|\widetilde{\vartheta}_{\text{MAP}})     

同样接着上面的例子来讲,在MAP中,我们需要在计算likelihood的基础上,加上一个关于参数p(在理论推导公式中为\theta) 的先验分布,并同时让likelihood和这个先验分布的乘积最大。我们通过日常经验得知,硬币正面朝上的概率通常应当是0.5左右,因此我们需要选择一个分布,使得从这个分布中sample出来的p值是在0.5附近的(也即该分布在0.5附近的概率较大)。 此时我们选择Beta分布(至于为什么要选择Beta分布,其原因会在阅读笔记第(三)部分讲):

\LARGE p(p|\alpha, \beta)=\frac{1}{B(\alpha, \beta)}p^{\alpha - 1}(1-p)^{\beta - 1}\triangleq Beta(p|\alpha, \beta)

其中的Beta function为  B(\alpha, \beta)=\frac{\Gamma(\alpha)\Gamma(\beta )}{\Gamma (\alpha+\beta )} (其中\Gamma为伽马函数,该公式在后面的推导中会用到)。

Beta分布的概率密度函数如下图所示:

可见,不同的\alpha\beta值会导致最终概率密度曲线形状出现极大的不同。

本例将选取\alpha=5, \beta=5 的hyperparameters取值,作为p参数所遵循的分布的参数。此时该概率密度函数的最大值在p=0.5时取得。此时,为了得到估计值\hat{p}_{MAP}, 我们对MAP中的目标函数求导,并令导数为0,:

\LARGE \frac{\partial}{\partial p}\mathcal{L}+log\ p(p)\\ =\frac{n^{(1)}}{p}-\frac{n^{(0)}}{1-p}+\frac{\alpha-1}{p}-\frac{\beta-1}{1-p}\stackrel{!}{=}0

解得,

\LARGE \hat{p}_{MAP}=\frac{n^{(1)}+\alpha-1}{n^{(1)}+n^{(0)}+\alpha + \beta -2}

由最终\hat{p}_{MAP}的表达式可见,估计的时候根本不必分辨式子里的参数是来源于数据,还是先验分布的参数\alpha\beta,它们统一都可以看作是“计数”(counts)。因此这里的\alpha\beta也常被称为“伪计数”(pseudo-word count)。

3. 贝叶斯推断(Bayesian Inference)

与MAP不同的是,贝叶斯估计方法不是在估计参数\vartheta 的一个确定的值,而是估计\vartheta 参数所处于的“分布”。换句话来说,贝叶斯方法不仅估计了那个能使得posteriori最大的\vartheta 的值,同样也估计了\vartheta 的期望和方差,从而衡量该估计值的confidence(或者说是quality)。因此,在贝叶斯推断中,首要的任务是估计基于Bayes' rule的后验概率:

\LARGE $$p(\vartheta|\mathcal{X})=\frac{p(\mathcal{X}|\vartheta)p(\vartheta)}{p(\mathcal{X})}$$                                                                 

每当我们接收到新的数据时,都可以通过该公式对参数\theta的分布进行更新。但此时由于我们不再局限于计算所谓“极大”的某一个项,所以我们不可避免地需要计算分母p(\mathcal{X}) ,而分母p(\mathcal{X}) 可以被表示成:

 \LARGE p(\mathcal{X})=\int_{\vartheta\in\Theta}p(\mathcal{X}|\vartheta)\ p(\vartheta)\ d\vartheta                                                                      

当新的数据被观测到时,后验概率p(\vartheta|\mathcal{X}) 应当能够自动进行调整。而上式中观测值的分布往往是在调整后验概率(也即贝叶斯推断)中较为棘手的一部分。

此时,在计算p(\widetilde{x}|\mathcal{X}) 的时候,我们可以通过贝叶斯公式进行精确求解:

\LARGE p(\widetilde{x}|\mathcal{X})\\ =\int_{\vartheta\in\Theta}\ p(\widetilde{x}|\vartheta)\ p(\vartheta|\mathcal{X})\ d\vartheta\\ =\int_{\vartheta\in\Theta}\ p(\widetilde{x}|\vartheta)\ \frac{p(\mathcal{X}|\vartheta)p(\vartheta)}{p(\mathcal{X})}\ d\vartheta             

此时我们接着利用原文中的例子,对例子中参数p的后验概率进行计算:

\LARGE p(p|C, \alpha, \beta)\\ =\frac{\prod_{i=1}^N\ p(C=c_i|p)\ p(p|\alpha, \beta)}{\int_0^1\ \prod_{i=1}^N\ p(C=c_i|p)\ p(p|\alpha, \beta)\ \text{d}p}\\ =\frac{p^{n^{(1)}}(1-p)^{n^{(0)}}\ \frac{1}{B(\alpha, \beta)}p^{\alpha-1}(1-p)^{\beta-1}}{Z}\\ =\frac{p^{[n^{(1)}+\alpha]-1}(1-p)^{[n^{(0)}+\beta]-1}}{B(n^{(1)}+\alpha, n^{(0)}+\beta)}\\ =Beta(p|n^{(1)}+\alpha, n^{(0)}+\beta)

此时我们可以根据Beta分布的性质,直接套用公式计算期望和方差:

\LARGE \langle p|C\rangle =\frac{n^{(1)}+\alpha}{n^{(1)}+n^{(0)}+\alpha+\beta}

\LARGE V\{p|C\}=\frac{(n^{(1)}+\alpha)(n^{(0)}+\beta)}{(N+\alpha+\beta+1)(N+\alpha+\beta)^2}

由于MAP中参数估计的值对应于p的分布中概率密度最大点,而该处的期望对应p的分布的均值,二者是不同的概念,因此二者的值未必相同,此处即是不同的值。

似乎我们并没有利用Bayesian inference的结果来对p(\widetilde{x}|\mathcal{X})进行计算?并不是。在本例中,上面所列公式中的p(\widetilde{x}|\mathcal{X})=\int_{\vartheta\in\Theta}\ p(\widetilde{x}|\vartheta)\ p(\vartheta|\mathcal{X})\ d\vartheta实际上可以写作:p(\widetilde{x}|\mathcal{X})=E_{p(\vartheta|\mathcal{X})}[p(\widetilde{x}|\vartheta)],而当\widetilde{x}=1的时候p(\widetilde{x}|\vartheta)=p, 所以等于是在计算参数p的均值。

 

此时我们可能会有一个疑问,为什么我们一下子列出来了三个方法?其意义呢?

首先,这三种方法在所考虑信息上面,有递进的关系(但并不意味着三种方法具有优劣之分):

ML聚焦于似然函数;

MAP具聚焦于最大后验概率,所以  此时你不仅需要考虑似然函数,也需要考虑先验函数prior;

以上两种方法最终都将估计出\vartheta 的一个具体的值。然而Bayesian inference的方法则是计算这个\vartheta 在已知观测数据基础之上的“分布”,此时我们的着眼点仍旧在后验概率上,但我们的目标此时不再是令这个概率值“尽可能大”,而是直接计算这个概率分布函数。所以我们此时就又需要多考虑一个分布函数,即Bayes's rule中式右的分母,即evidence。由于MAP计算的实际上是后验概率分布中的“众数”,而通过Bayesian inference,我们可以直接得到关于这个分布的一切信息。当我们得到参数的分布之后,我们就可以计算出该参数的“期望”,而期望比众数更具有一般性。所以看起来Bayesian inference是一个更好的选择。然而,很多时候贝叶斯公式中的分母evidence是intractable的(比如LDA中),所以人们就退而求其次,去选择MLE或是MAP的方法了。

总结:我们首先需要明确的是,我们本节在干什么?显然,我们本节实际上是在进行“参数估计”。那么我们要进行什么样的参数估计?通过已知的observations,找到一组参数,使得我们预设的distribution在这组参数下,能够尽可能解释这些observations为何出现(尽可能拟合这组数据)。如果我们单单顾及找参数并“模仿”已知的数据(ML),那么就有可能为了尽可能模仿这些数据而造成overfitting,所以我们可以选择在参数估计中加入“人工干预”:即prior belief,来尽量回避overfitting问题。但这样就结束了吗?其实在加入人工干预的时候,一方面我们会担心这个“干预”可能是有问题的,此时反而会对参数的估计造成伤害,从而降低模型的performance;另一方面,我们应该时刻记住我们的目标:p(\widetilde{x}|\mathcal{X})=\int_{\vartheta\in\Theta}p(\widetilde{x}|\vartheta)\ p(\vartheta|\mathcal{X})d\vartheta,在前两种方法中,我们都对这个式子进行了近似处理,即将被积函数中的likelihood这一项改成了constant的。那么,我们能否消除这种近似呢?答案就是利用Bayesian inference,对该被积函数中已知evidence下的参数\theta的分布进行更为精确的计算推导,也就是根据evidence(observations)算出\theta的分布,因此这也就是为什么我们需要Bayesian inference的原因。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This textbook evolved from a course in geophysical inverse methods taught during the past two decades at New Mexico Tech, first by Rick Aster and, subsequently, jointly between Rick Aster and Brian Borchers. The audience for the course has included a broad range of first- or second-year graduate students (and occasionally advanced under- graduates) from geophysics, hydrology, mathematics, astrophysics, and other disciplines. Cliff Thurber joined this collaboration during the production of the first edition and has taught a similar course at the University of Wisconsin-Madison. Our principal goal for this text is to promote fundamental understanding of param- eter estimation and inverse problem philosophy and methodology, specifically regarding such key issues as uncertainty, ill-posedness, regularization, bias, and resolution. We emphasize theoretical points with illustrative examples, and MATLAB codes that imple- ment these examples are provided on a companion website. Throughout the examples and exercises, a web icon indicates that there is additional material on the website. Exercises include a mix of applied and theoretical problems. This book has necessarily had to distill a tremendous body of mathematics and science going back to (at least) Newton and Gauss. We hope that it will continue to find a broad audience of students and professionals interested in the general problem of estimating physical models from data. Because this is an introductory text surveying a very broad field, we have not been able to go into great depth. However, each chapter has a “notes and further reading” section to help guide the reader to further explo- ration of specific topics. Where appropriate, we have also directly referenced research contributions to the field. Some advanced topics have been deliberately left out of this book because of space limitations and/or because we expect that many readers would not be sufficiently famil- iar with the required mathematics. For example, readers with a strong mathematical background may be surprised that we primarily consider inverse problems with discrete data and discretized models. By doing this we avoid much of the technical complexity of functional analysis. Some advanced applications and topics that we have omitted include inverse scattering problems, seismic diffraction tomography, wavelets, data assimilation, simulated annealing, and expectation maximization methods. We expect that readers of this book will have prior familiarity with calculus, dif- ferential equations, linear algebra, probability, and statistics at the undergraduate level. In our experience, many students can benefit from at least a review of these topics, and we commonly spend the first two to three weeks of the course reviewing material from
引用\[1\]: "Classification, parameter estimation, and state estimation: an engineering approach using MATLAB" 是一本关于使用MATLAB进行分类、参数估计和状态估计的工程方法的书籍标题。引用\[3\]: "Classification, Parameter Estimation and State Estimation" 是一本实用指南,适用于数据分析师、测量系统设计师和对使用MATLAB进行高级测量系统感兴趣的研究生学生。该书介绍了一个名为"Prtools"的强大MATLAB工具箱,用于模式识别,该工具箱由合著者之一、代尔夫特理工大学的B. Duin编写和拥有。 问题: Parameter Estimation Toolbox是什么? 回答: "Parameter Estimation Toolbox" 是一个MATLAB工具箱,用于参数估计。它提供了一套工具和函数,用于处理参数估计问题,包括设置参数初值、确定参数范围、进行参数估计和验证模型精度。这个工具箱可以帮助数据分析师和测量系统设计师进行参数估计和模型验证的工作。 #### 引用[.reference_title] - *1* *3* [分类、参数估计和状态估计:基于MATLAB的工程方法-Classification, parameter estimation, and state ...](https://blog.csdn.net/weixin_42392054/article/details/115924568)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [电池SOC仿真系列-基于Parameter Estimation Toolbox的电池参数辨识](https://blog.csdn.net/c85759351/article/details/112822098)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值