2

“Machine learning - Hidden Markov Model (HMM)”

 2 years ago
source link: https://jhui.github.io/2017/01/15/Machine-learning-Hidden-Markov-Model-HMM/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Hidden Markov Model (HMM)

There are hidden states of a system that we cannot observe directly. 20% chance that we go to watch a movie when we are happy but also 40% chance when we are upset. People may tell you what they did (observable) but unlikely tell you the truth whether they were happy or upset (the hidden state). Given the information on the chance of what people do when they are upset or happy, we can uncover the hidden state (happy or upset) by knowing what they did.

Prior belief: Here is our belief on the chance of being happy and upset.

xP(happy)P(upset)∈happy,upset=0.8=0.2x∈happy,upsetP(happy)=0.8P(upset)=0.2

Observables (what we do):

y∈movie,book,party,dinningy∈movie,book,party,dinning

Here is the likelihood: the chance of what will we do when we are happy or upset.

  movie book party dinning
Given being happy 0.2 0.2 0.4 0.2
Given being upset 0.4 0.3 0.1 0.2

Compute the posterior:

P(x|y)P(happy|party)P(happy|party)=P(y|x)P(x)P(y)=P(party|happy)P(happy)P(party)=P(party|happy)P(happy)P(party|happy)P(happy)+P(party|upset)P(upset)=0.4∗0.80.4∗0.8+0.1∗0.2=0.94P(x|y)=P(y|x)P(x)P(y)P(happy|party)=P(party|happy)P(happy)P(party)P(happy|party)=P(party|happy)P(happy)P(party|happy)P(happy)+P(party|upset)P(upset)=0.4∗0.80.4∗0.8+0.1∗0.2=0.94

Hence, the chance that a person goes to party because he/she is happy is 94%. This is pretty high because we have a high chance of being happy and also high chance to go party when we are happy.

In reality, being happy or upset is not independent. Instead, it can be better model by a Markov Model. Here is the transition probability from xtxt to xt+1xt+1.

stt1.png

For example,

P(Happyt+1|Happyt)=0.99P(Happyt+1|Happyt)=0.99

he Markhov process for 2 timesteps is:

mhp.png
P(x0,x1,x2,y1,y2)=P(x0)P(y1|x1)P(y2|x2)P(x1|x0)P(x2|x1)P(x0,x1,x2,y1,y2)=P(x0)P(y1|x1)P(y2|x2)P(x1|x0)P(x2|x1)

To recap,

P(x0)P(x0):

P(x0=happy)P(x0=upset)=0.8=0.2P(x0=happy)=0.8P(x0=upset)=0.2

P(xt+1|xt)P(xt+1|xt):

stt2.png

P(yt|xt)P(yt|xt):

  movie book party dinning
Given being happy 0.2 0.2 0.4 0.2
Given being upset 0.4 0.3 0.1 0.2

Our objective is to calculate:

P(xt|y1:t)y1y2y3=P(xt|y1,y2,⋯,yt)→P(x1|y1)→P(x2|y1,y2)→P(x3|y1,y2,y3)⋯P(xt|y1:t)=P(xt|y1,y2,⋯,yt)y1→P(x1|y1)y2→P(x2|y1,y2)y3→P(x3|y1,y2,y3)⋯

Given:

P(A|C)P(A,B|C)=∑BP(A,B|C)=P(A|B,C)P(B|C)P(A|C)=∑BP(A,B|C)P(A,B|C)=P(A|B,C)P(B|C)

We re-calculate our objective:

P(xt|y1:t−1)=∑xt−1P(xt,xt−1|y1:t−1)=∑xt−1P(xt|xt−1,y1:t−1)P(xt−1|y1:t−1)=∑xt−1P(xt|xt−1)P(xt−1|y1:t−1)P(xt|y1:t−1)=∑xt−1P(xt,xt−1|y1:t−1)=∑xt−1P(xt|xt−1,y1:t−1)P(xt−1|y1:t−1)=∑xt−1P(xt|xt−1)P(xt−1|y1:t−1)

Given a modified Bayes’ theorem:

P(A|B,C)=P(B|A,C)P(A|C)P(B|C)P(A|B,C)=P(B|A,C)P(A|C)P(B|C)

To make prediction:

P(xt|y1:t)=P(xt|yt−1,y1:t−1)=P(A|B,C)=P(yt|xt,y1:t−1)P(xt|y1:t−1)∑xtP(yt|xt,y1:t−1)P(xt|y1:t−1)=P(yt|xt)P(xt|y1:t−1)∑xtP(yt|xt)P(xt|y1:t−1)P(xt|y1:t)=P(xt|yt−1,y1:t−1)=P(A|B,C)=P(yt|xt,y1:t−1)P(xt|y1:t−1)∑xtP(yt|xt,y1:t−1)P(xt|y1:t−1)=P(yt|xt)P(xt|y1:t−1)∑xtP(yt|xt)P(xt|y1:t−1)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK