LDA主题模型
LDA是一种基于概率模型的主题模型算法(generative probabilistic model),用来识别大规模文档集或者语料库中隐含的主题信息。对于语料库中的每篇文档,LDA定义了如下生成过程:
对每一篇文档,从主题分布中抽一个主题 从上述被抽到的主题对应的单词分布中抽一个单词 重复上述过程直至遍历文档中的每个词
LDA认为每篇文档是多个主题混合而成,而每个主题可以由多个词的概率表征。
背景知识
共轭前驱分布(conjugate prior)
In Bayesian probability theory, if the posterior distribution p(θ|x)" role="presentation">p(θ|x) are in the same family as the prior distribution p(θ)" role="presentation">p(θ), the prior and the posterior are then called conjugate distributions, and the prior is called a conjugate prior for the likelihood function.
如果后验分布和先验分布同属于一个函数族,那么后验和先验称为共轭分布,先验被称为似然函数的共轭先验分布。Beta分布是二项分布的共轭先验分布,Dirichlet分布是多项分布的共轭先验分布。
根据贝叶斯规则,后验分布=似然函数*先验分布:
p(θ|x)=p(x|θ)p(θ)p(x)=p(x|θ)p(θ)∫p(x|θ)p(θ)dθ∝p(x|θ)p(θ)" role="presentation">p(θ|x)=p(x|θ)p(θ)p(x)=p(x|θ)p(θ)∫p(x|θ)p(θ)dθ∝p(x|θ)p(θ)
其中p(x|θ)" role="presentation">p(x|θ)为likelihood,p(θ)" role="presentation">p(θ)为prior belief,p(x)" role="presentation">p(x)为evidence。
Dirichlet Distribution
Dirichlet分布是描述k(k≥2)" role="presentation">k(k≥2)个变量X1,X2,⋯,Xk" role="presentation">X1,X2,,Xk的概率分布,其中xi∈(0,1),∑i=1kxi=1" role="presentation">xi∈(0,1),∑ki=1xi=1。Dirichlet分布的参数为α→={α1,α2,⋯,αk}" role="presentation">α={α1,α2,,αk},其中αi>0" role="presentation">αi>0(不需要是整数,只需要是正实数即可)。
αi" role="presentation">
αi越大,赋予
Xi" role="presentation">
Xi的权重就越多(
∑ixi=1" role="presentation">
∑ixi=1) 当
αi" role="presentation">
αi相等的时候,分布是对称的 当
αi<1" role="presentation">
αi<1时,相当于一个anti-weight把
xi" role="presentation">
xi 推到一些极点(push away toward extremes) 当
αi>1" role="presentation">
αi>1时,会使得
xi" role="presentation">
xi聚集在中心值
α1=⋯=αk=1" role="presentation">α1==αk=1时,均匀分布
下图所展示的是三元Dirichlet分布,参数分别为:
1. α1=α2=α3=1" role="presentation">α1=α2=α3=1
2. α1=α2=α3=10" role="presentation">α1=α2=α3=10
3. α1=1,α2=10,α3=5" role="presentation">α1=1,α2=10,α3=5
4. α1=α2=α3=0.2" role="presentation">α1=α2=α3=0.2
LDA
在LDA模型中,一篇文档生成的方式如下:
1. 从狄利克雷分布α→" role="presentation">α中取样生成文档m" role="presentation">m的主题分布 θ→m" role="presentation">θm
2. 从主题的多项式分布θ→m" role="presentation">θm中取样生成文档m" role="presentation">m第 n" role="presentation">n个词的主题zm,n" role="presentation">zm,n
3. 从K" role="presentation">K个topic-word的狄利克雷分布中,选择k=zm,n" role="presentation">k=zm,n的Dirichlet 分布ϕ→k" role="presentation">k,取样生成主题对应的词语分布
4. 从词语的多项式分布中采样最终生成词语wm,n" role="presentation">wm,n
通俗理解LDA
LDA算法漫游指南
What exactly is the alpha in the Dirichlet distribution
LDA数学八卦