隐马尔科夫模型
2017-10-28 本文已影响29人
初七123
模型定义
隐马尔科夫模型是关于时序的概率模型,描述由一个隐藏的马尔科夫链随机生成的状态随序列,并且由状态序列生成观测序列的过程。不同于分类和回归,其主要用于标注问题
![](https://img.haomeiwen.com/i1507799/586a72d098d1e96a.png)
![](http://upload-images.jianshu.io/upload_images/1507799-2da36877b2b90cc2.png)
观测序列的生成
1.由初始概率 π 生成初始隐藏状态 i(1)
2.令 t = 1
3.按照隐藏状态 i(t) 的观测分布 b(j,k) 生成观测状态 o(t)
4.按照转移矩阵 a(i,j) 生成 i(t+1)
5.t = t + 1, 直到 t < T
概率计算算法
概率计算问题的定义:已知模型参数和观测序列,求改观测序列出现的概率
通常来说我们可以穷举马尔科夫链的所有情况,得到给定观测序列出现的次数,便可基于频率计算出观测序列的概率。然而,这种算法时间复杂度太高。所以就有了下面的算法:
前向算法
前向概率
给定隐马尔科夫模型,t 时刻其观测序列为 {o(1), o(2), ..., o(t)} 并且隐状态为 q(i)的概率为:
![](http://upload-images.jianshu.io/upload_images/1507799-617d5a0f1479e293.png)
前向算法
![](http://upload-images.jianshu.io/upload_images/1507799-c328376c033ae12e.png)
前向算法的实质是基于“状态序列路径结构”的递推算法。其高效之处在于每一次计算直接引用上一次计算的结果。
学习问题
模型学习就是给定训练数据求隐马尔科夫模型参数
监督学习方法
如果给定观测序列以及相应的状态序列,可以用极大似然估计来求解
![](http://upload-images.jianshu.io/upload_images/1507799-df99379f8323a680.png)
![](http://upload-images.jianshu.io/upload_images/1507799-b58c2f020068445e.png)
![](http://upload-images.jianshu.io/upload_images/1507799-efa8278f7e18ba6c.png)
非监督学习方法
此时我们只有观测序列,并不知道对应的隐状态序列。所以我们需用EM算法来做包含隐变量的极大似然估计。这又被称之为Baum-Welch算法
省略EM算法推导过程可得
![](http://upload-images.jianshu.io/upload_images/1507799-7a692f39edad3fd9.png)
![](http://upload-images.jianshu.io/upload_images/1507799-d4f6b2523de8258f.png)
算法中用到的公式
![](http://upload-images.jianshu.io/upload_images/1507799-30e950c8bc60476e.png)
![](http://upload-images.jianshu.io/upload_images/1507799-5b5755b78228c416.png)
![](http://upload-images.jianshu.io/upload_images/1507799-f001c3223e030e77.png)
![](http://upload-images.jianshu.io/upload_images/1507799-10f0a433c8d780d3.png)
解码问题
给定模型和观测序列,求隐状态序列
这里给出一种简单的算法
![](http://upload-images.jianshu.io/upload_images/1507799-ae0fc64dbdf50b14.png)
参考
《统计学习方法》