Basic help using hmm to add sequence

I am very new to Matlab, the hidden Markov model and machine learning, and try to classify a specific sequence of signals. Please let me know if my approach is right:

  • create a transition matrix N to N and fill in random values ​​that add up to 1 for each row. (N will be the number of states)
  • create an N / M radiation / observation matrix and fill in random values ​​that add up to 1 for each row
  • convert different instances of the sequence (that is, each instance will say the word "hello") into one long stream and feed each stream to the hmm train function to:

    new_transition_matrix old_transition_matrix = hmmtrain (sequence, old_transition_matrix, old_emission_matrix)

  • give the final transition and emission matrix for hmm decoding with an unknown sequence to give the probability ie [posterior_states logrithmic_probability] = hmmdecode( sequence, final_transition_matrix,final_emission_matris)

+4
source share
1 answer

1. and 2. are correct. You must be careful that the source transition and radiation matrices are not completely homogeneous, they must be slightly randomized for training to work.

3. "Hello" , , .

, Hello: [1,0,1,1,0,0]. 3 'Hello' , :

data = [1,0,1,1,0,0,1,0,1,1,0,0,1,0,1,1,0,0]

, , :

data = [1,0,1,1,0,0; 1,0,1,1,0,0; 1,0,1,1,0,0].

MatLab, HMM toolbox Murphy. , HMM :

M = 3;
N  = 2;

% "true" parameters
prior0 = normalise(rand(N ,1));
transmat0 = mk_stochastic(rand(N ,N ));
obsmat0 = mk_stochastic(rand(N ,M));

% training data: a 5*6 matrix, e.g. 5 different 'Hello' sequences of length 6
number_of_seq = 5;
seq_len= 6;
data = dhmm_sample(prior0, transmat0, obsmat0, number_of_seq, seq_len);

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

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

4. , , - , HMM:

% use model to compute log[P(Obs|model)]
loglik = dhmm_logprob(data, prior2, transmat2, obsmat2)

: , , - .

, .

+3

All Articles