I use HMM to predict the behavior of humans. Hidden states are Rest walk eat and observations are inside, outside and snack respectively.
hState = ['Rset', 'Walk', 'Eat']
Obs = ['Inside 1', 'Outside 2', 'Snack 3']
order = [1, 2, 1, 2, 3 ,2, 2, 3, 1, 2 ,2, 2, 1, 2]
no = 3
sProb = np.array([0.1, 0.8, 0.1])
tProb = np.array([[0.2, 0.2, 0.6],
[0.1, 0.8, 0.1],
[0.6, 0.1, 0.3]])
eProb = np.array([[0.7, 0.2, 0.1],
[0.1, 0.6, 0.3],
[0.2, 0.3, 0.5]])
h = hmm.MultinomialHMM(3, "full", sProb, tProb)
h.emissionprob_ = eProb
oreder1 = np.array([order]).T
result= hmm.GaussianHMM(n_components=no).fit(oreder1)
result.predict(oreder1)
But the result is changed whenever I run the code again. Sequences of the result are correct but the hidden state id is change The result of the first time run
array([2, 1, 2, 1, 0, 1, 1, 0, 2, 1, 1, 1, 2, 1])
The result of the second time run
array([0, 1, 0, 1, 2, 1, 1, 2, 0, 1, 1, 1, 0, 1])
What I want to know is how can I get constant value for each run or how to finalize the model. Thank you for your answer in advance.