Probabilities going to infinity, NaN, or 0, but never in (0, 1].

188 views
Skip to first unread message

Jose Ramirez

unread,
Feb 9, 2012, 3:45:11 PM2/9/12
to Jahmm HMM library
Hello everyone!

I'm using jahmm to build a HMM classifier. So, I've set up the model
with 5 states and gaussian distributions. So far so good. After the
model is trained (the initial guess for the forward backward learning
algorithm is the result of the first iteration of the K-Means
algorithm with the training set as input), when it comes to calculate
the probability of a given observation sequence (each sequence has a
size of 300), the result (if it isn't equal to 0) goes to infinity, or
NaN, but never in (0, 1].

Frankly, I've been reading this site for a while to see if anyone has
had this same problem, but seems to me that I'm doing something wrong
here.

I've tried many possible combinations, and all of them yield the same
results (probabilities going to infinity, NaN, or 0, but never in (0,
1]): using scaled learners, and changing the distribution factory from
gaussians to gaussian mixtures, to multivariate gaussians (thus
changing the observation sequences accordingly).

I even thought that the problem had to do with the observation
sequences, i.e., something with the data itself, maybe not enough data
is being used (the training set for a model has 18 sequences), but the
trained models seem to be fine (they were written to files to check
their parameters and all, nothing weird at this end).

And sincerely, I'm stuck. Any feedback on any mistake would be
appreciated. If you need any code to see what happens, please let me
know as well.

Jean-Marc François

unread,
Feb 11, 2012, 11:10:41 AM2/11/12
to jahmm-...@googlegroups.com
Hi,

Since your model has a small number of states, you could manually
check if the result of the learning phase seems right. A wrong result
could be caused by a too small number of learning sequences for
instance (that could lead to wrong pi values, the probability that a
given state is the initial state).

My best guess would be that the learning algorithm or the sequence
probability estimation has numerical stability problems because of the
length of your sequences: it seems normal that the probability of such
a long sequence is about 0, it seems that it only makes sense to
compute the log of the said probability.

Hopefully there is a way to resolve this problem: looks at the
BaumWelchScaledLearner and ForwardBackwardScaledCalculator classes.
Another (simpler) option would be to cut your sequences in small
pieces, if your particular problem allows it.

Hth,
JM

> --
> You received this message because you are subscribed to the Google Groups "Jahmm HMM library" group.
> To post to this group, send email to jahmm-...@googlegroups.com.
> To unsubscribe from this group, send email to jahmm-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jahmm-discuss?hl=en.
>

Reply all
Reply to author
Forward
0 new messages