Question

I try to run sample code from http://scikit-learn.org/stable/modules/hmm.html:

import numpy as np
from sklearn import hmm

startprob = np.array([0.6, 0.3, 0.1])
transmat = np.array([[0.7, 0.2, 0.1], [0.3, 0.5, 0.2], [0.3, 0.3, 0.4]])
means = np.array([[0.0, 0.0], [3.0, -3.0], [5.0, 10.0]])
covars = np.tile(np.identity(2), (3, 1, 1))
model = hmm.GaussianHMM(3, "full", startprob, transmat)
model.means_ = means
model.covars_ = covars
X, Z = model.sample(150)

model2 = hmm.GaussianHMM(3, "full")
model2.fit([X])

and scored log probability for observation X under the model:

print (model2.score(X))

I would expect number in interval <0,1>, but very low negative value is giving. For example above, the score returned -554.979039475. Im not understand what it means.

Please, can you someone advise me?

From doc:
score(obs): Compute the log probability under the model
Returns : Log likelihood of the obs.

scklearn hmm.score documentation

Was it helpful?

Solution

Log probability is the log of a probability. In this case, the probability is

>>> np.exp(-554.979039475)
9.4550881914378009e-242
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top