隐马模型
机器学习
Basic Concepts
Let Q={q1,q2,…,qN} denote state set, V={v1,v2,…,vM} denote observation set, I=(i1,i2,…,iN) denote state sequence, and O=(o1,o2,…,oN) denote corresponding observation sequence.
A=[aij]N×N is state transfer matrix, where
aij=P(ii+1=qj∣it=qi),i=1,2,…,N;j=1,2,…,N
B=[bij]N×M is observation probability matrix, where
bj(k)=P(ot=vk∣it=qj),k=1,…,M;j=1,…,N
π is initial state probability vector, where πi=P(i1=qi).
Calculalate Probability
Given λ=(A,B,π) and O, find P(O∣λ).
By force
P(O∣λ)=∑IP(O∣I,λ)P(I∣λ)
Forward
Define forward probability as
αt(i)=P(o1,o2,…,ot,it=qi∣λ)
Input: Hidden markov model λ and observation sequance O;
Output: Observation sequence probability P(O∣λ).
- Initialize:
α1(i)=πibi(o1)
- Deduct:
αt+1(i)=⎡⎣∑j=1Nαt(j)aji⎤⎦bi(ot+1)
- Terminate
P(O∣λ)=∑i=1NαT(i)
Backward
Define backward probability as
βt(i)=P(ot+1,…,oT∣it=qi,λ)
Input: Hidden markov model λ and observation sequance O;
Output: Observation sequence probability P(O∣λ).
- Initialize:
β1(i)=1
- Deduct:
αt(i)=⎡⎣∑j=1Naijbj(ot+1)βt+1(j)⎤⎦
- Terminate
P(O∣λ)=∑i=1Nπibi(o1)β1(i)
Some probabilities and expectations
Let γt(i) denote probabity at state qi at time t
γt(i)=P(it=qi∣O,λ)=αt(i)βt(i)∑Nj=1αt(i)βt(i)
Learning Algorithm
TODO: Solve it with EM.
Predication Algorithm
Approximation
Most likely state i∗t at time t is
i∗t=argmax1≤i≤N[γt(i)]
It's not necessary the most likely state sequence, but it's still quite useful.
Viterbi algorithm
Init
δ1(i)=πibi(o1),i=1,2,…,N
ψi(i)=0,i=1,2,…,N
Deduct, for t=2,…,T
δt(i)=ϕt(i)=max1≤j<N[δt−1(j)aji]bi(ot),argmax1≤j<N(i)[δt−1(j)aji],i=1,2,…,Ni=1,2,…,N(19)(20)
Terminate
P∗=max1≤j<NδT(i)
i∗T=argmax1≤j<N[δT(i)]