3
$\begingroup$

I was working on a project on music genre classification and decided to use an hmm to model my data. After extracting the mfccs' from multiple song clips I get multiple matrices of size 13 * x (depending on song length).

From what I understand hmm_train cannot be used for sequences of vectors and murphyk's toolbox might work. I tried modifying the demo file as follows to try a single song but I'm getting the error 'Attempted to access obsmat(:,61.6357); index must be a positive integer or logical..'

O = 5;
Q = 10;

v=wavread('We are the champions');
coeff=melfcc(v);
data=coeff';

% initial guess of parameters
prior1 = normalise(rand(Q,1));
transmat1 = mk_stochastic(rand(Q,Q));
obsmat1 = mk_stochastic(rand(Q,O));

% improve guess of parameters using EM
[LL, prior2, transmat2, obsmat2] = dhmm_em(data, prior1, transmat1, obsmat1, 'max_iter', 5);
LL    

I haven't worked on this stuff before so I apologize in advance if my question comes across as really basic. It would be great if somebody could tell me where I'm going wrong. Also for multiple clips, should I simply append the matrices generated to the one I'm supplying above? Thanks.

Edit: It turns out that the above hmm can only be applied to discrete values which is possibly why I was getting errors. It seems I have to use another function for 'gaussian output' instead, mhmm_em. I'll post another question to figure out its working.

$\endgroup$
  • $\begingroup$ hello am facing the same problem Attempted to access obsmat(:,0.856506); index must be a positive integer or logical. how did you solve it? $\endgroup$ – user26511 Nov 26 '16 at 6:11
  • $\begingroup$ Assuming you made the same mistake as me, you probably provided continuous values, so had decimals in your data. The function above can only take discrete values, i.e., integers only. $\endgroup$ – Anshul G. Nov 29 '16 at 19:20
2
$\begingroup$

Edit: It turns out that the above hmm can only be applied to discrete values which is possibly why I was getting errors. It seems I have to use another function for 'gaussian output' instead, mhmm_em. I'll post another question to figure out its working.

In order to clarify this a bit. The functions you were trying to use are indeed defined for discrete data represented by probability mass functions.

When working with continuous data and modeling them with an HMM, one needs to decide what probability distribution will best represent the data. When the data has an unbounded support, the Gaussian is often a good first choice, and most machine leaning toolboxes have built-in functions for the training of these HMMs. However, an HMM can be trained with other probability distributions such as the Dirichlet distribution (if your data is proportional), or the Student-t, Weibull distributions,...

Keep in mind that the distribution you choose is a modeling hypothesis that you do with respect to the data you have. If the hypothesis does not make sense, the results might not be accurate. Unfortunately, the use of these other distributions mostly rely on you to either, derive and code the needed equations (however, in some cases the equations are available in some scientific papers).

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for the info! In the end I decided to cluster my data and then feed the discrete data points for the previous function or the inbuilt matlab one (too many parameters in the gaussian one which I was unable to figure). $\endgroup$ – Anshul G. Nov 6 '16 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.