Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the ways of deciding probabilities in hidden markov models?

I am starting to learn hidden markov models and on the wiki page, as well as on github there are alot of examples but most of the probabilities are already there(70% change of rain, 30% chance of changing state, etc..). The spell checking or sentences examples, seem to study books and then rank the probabilities of words.

So does the markov model include a way of figuring out the probabilities or are we suppose to some other other model to pre-calculate it?

Sorry if this question is off. I think its straightforward how the hidden markov model selects probable sequences but the probability part is a bit grey to me(because its often provided). Examples or any info would be great.


For those not familiar with markov models, here's an example(from wikipedia) http://en.wikipedia.org/wiki/Viterbi_algorithm and http://en.wikipedia.org/wiki/Hidden_Markov_model

#!/usr/bin/env python

states = ('Rainy', 'Sunny')

observations = ('walk', 'shop', 'clean')

start_probability = {'Rainy': 0.6, 'Sunny': 0.4}

transition_probability = {
   'Rainy' : {'Rainy': 0.7, 'Sunny': 0.3},
   'Sunny' : {'Rainy': 0.4, 'Sunny': 0.6},
   }

emission_probability = {
   'Rainy' : {'walk': 0.1, 'shop': 0.4, 'clean': 0.5},
   'Sunny' : {'walk': 0.6, 'shop': 0.3, 'clean': 0.1},
   }

#application code
# Helps visualize the steps of Viterbi.
def print_dptable(V):
    print "    ",
    for i in range(len(V)): print "%7s" % ("%d" % i),
    print

    for y in V[0].keys():
        print "%.5s: " % y,
        for t in range(len(V)):
            print "%.7s" % ("%f" % V[t][y]),
        print

def viterbi(obs, states, start_p, trans_p, emit_p):
    V = [{}]
    path = {}

    # Initialize base cases (t == 0)
    for y in states:
        V[0][y] = start_p[y] * emit_p[y][obs[0]]
        path[y] = [y]

    # Run Viterbi for t > 0
    for t in range(1,len(obs)):
        V.append({})
        newpath = {}

        for y in states:
            (prob, state) = max([(V[t-1][y0] * trans_p[y0][y] * emit_p[y][obs[t]], y0) for y0 in states])
            V[t][y] = prob
            newpath[y] = path[state] + [y]

        # Don't need to remember the old paths
        path = newpath

    print_dptable(V)
    (prob, state) = max([(V[len(obs) - 1][y], y) for y in states])
    return (prob, path[state])



#start trigger
def example():
    return viterbi(observations,
                   states,
                   start_probability,
                   transition_probability,
                   emission_probability)
print example()
like image 925
Lostsoul Avatar asked Oct 28 '11 18:10

Lostsoul


People also ask

How do you find the probability of a Markov chain?

The Markov chain X(t) is time-homogeneous if P(Xn+1 = j|Xn = i) = P(X1 = j|X0 = i), i.e. the transition probabilities do not depend on time n. If this is the case, we write pij = P(X1 = j|X0 = i) for the probability to go from i to j in one step, and P = (pij) for the transition matrix.

What are emission probabilities in hidden Markov models?

(HMM) Emission Probability is the probability of observation of network event data conditioned on the state of the mobile device, in a dynamical approach based on a hidden Markov model.

What are the 3 fundamental problems Markov models are characterized with?

HMM provides solution of three problems : evaluation, decoding and learning to find most likelihood classification.

What are the important components of a hidden Markov model?

A HMM consists of two components. Each HMM contains a series of discrete-state, time-homologous, first-order Markov chains (MC) with suitable transition probabilities between states and an initial distribution.


1 Answers

You're looking for an EM (expectation maximization) algorithm to compute the unknown parameters from sets of observed sequences. Probably the most commonly used is the Baum-Welch algorithm, which uses the forward-backward algorithm.

For reference, here is a set of slides I've used previously to review HMMs. It has a nice overview of Forward-Backward, Viterbi, and Baum-Welch

like image 128
Dusty Avatar answered Sep 30 '22 07:09

Dusty