Skip to content

Instantly share code, notes, and snippets.

@minesh1291
Forked from kangeugine/hmm_1.py
Created May 23, 2019 11:37
Show Gist options
  • Save minesh1291/fd55bd606de43f5f6388a619e3434d3d to your computer and use it in GitHub Desktop.
Save minesh1291/fd55bd606de43f5f6388a619e3434d3d to your computer and use it in GitHub Desktop.
HMM
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},
}
from hmmlearn import hmm
import numpy as np
model = MultinomialHMM(n_components=2)
model.startprob_ = np.array([0.6, 0.4])
model.transmat_ = np.array([[0.7, 0.3],
[0.4, 0.6]])
model.emissionprob_ = np.array([[0.1, 0.4, 0.5],
[0.6, 0.3, 0.1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment