# How to use prior probability in inferencing from HMM for activity recognition?

I am interested in modelling human activities using sensor data with HMMs and would like to incorporate prior knowledge during inference. The normal procedure is to model K different activities with K separate HMMs. To test an unknown sequence, compute its likelihood from each of the HMMs and the HMM with maximum value is assigned as the class label. This is all done under the assumption that priors over HMM are uniform.

A problem can arise when one of the class is rare or unusual and its prior probability may be very low in comparison to other classes and therefore the uniform priors may not be a good assumption. Therefore, I am interested in posterior probability and not just the likelihood to capture the combined effect. My observations are continuous (features extracted from sensor) and not discrete values. My questions are:

1. Can inference be done using a bayesian network type approach that include multiplication of prior with likelihood?

2. In my case the prior will be the count of activities available per HMM. Can that be estimated using a dirichlet prior to avoid zero-count problem for rare class (assuming I approximate an HMM for a rare class). Does that make sense?

3. The multivariate observation data is approximated using single gaussian (and not mixtures), in that case likelihood will be gaussian?, can it be mixed with dirichlet prior to compute posterior probability? or the likelihood is still multinomial as it represents K different outcomes from K different HMMs?

Sorry if I have mixed with some of the basic concepts, I am new and I seek guidance to move further.

## 1 Answer

My first reaction is to wonder if there's not an easier way to do what you're trying to do here. Are these HMMs models where the parameters have already been selected and where you're just looking at observations from them? If that's the case, then I think that's just an MM but that's semantics. If it's not and you're trying to actively fit the parameters of these HMMs at the same time as you're determining posterior likelihood, then I have some doubts about whether what you're doing is going to work.

I'm assuming that you have already fit the parameters of each HMM representing the state transition probabilities and the output probabilities. If that's the case, then given a sequence of observed outputs (or actions, in this case) you can compute the likelihood from each of the HMMs and using a prior will work fine.

As for point 2, the prior will be multinomial, not Dirichlet. You just need to state P(Class 1), P(Class 2) and so forth. If you want to put a prior on the prior, you can do that and in that case it would be Dirichlet but I doubt that's necessary. A Dirichlet prior is used when the outcome is multinomial, in your case the outcome data is generated based on a discrete mixture of Markov Models. If you want to have the parameters of the prior be a function of other data, you can do that. If you want it to be proportional to the count of activities available, that's fine. The best way to avoid problems from zero-occurring classes is just to add a small number like 1 to each of the counts.

On question 3, I'm not at all sure what you mean here. The multivariate observation data? I thought the observation was a sequence of actions? How would you approximate a sequence of discrete outputs using a single Gaussian? If you're truly using a Markov Model, the likelihood should be a sequential product of conditional probabilities, each of which should be multinomial. Technically this will be more like conditional likelihood than actual likelihood, but that will make your life a lot easier. But you can multiply that by the prior to get the posterior and choose the most likely among the posterior probabilities.

• Thanks for your response. To clarify, each HMM is trained on fixed-length short sequences (say 2 sec) and parameters computed from them. The observations (sensor readings) are continuous and several features are extracted from each sequence, and each feature is approximated with single gaussian. I wanted to use prior because some activities are less likely than others for e.g. sitting is more likely than jumping and decision based on just likelihood is not right. One way is to use individual activity count as prior or other as some distribution like Dirichlet. What do you suggest? – Shehroz Aug 20 '13 at 4:53
• Using a prior seems perfectly reasonable, but a Dirichlet is not what you're looking for. Just a regular multinomial, where you specify each probability. If you need to you can add a small number to each count to avoid zero prior probability. – Mike Nute Aug 20 '13 at 15:27