title: How to train HMM model with multiple sequence of observations - symbol pairs
body: <p>I am trying to train HMM model to find model parameters for Part of Speech tagging problem. </p>
  
  <p>I am using PythonHMM package from following resource:
  <a href="https://github.com/jason2506/PythonHMM" rel="nofollow noreferrer">https://github.com/jason2506/PythonHMM</a></p>
  
  <p>Original training data could be like this:</p>
  
  <pre><code>Sr.No.  Observations
  1       killer/N clown/N
  2       killer/N problem/N
  3       crazy/A problem/N
  4       crazy/A clown/N
  5       problem/N crazy/A clown/N
  6       clown/N crazy/A killer/N
  </code></pre>
  
  <p>I have created a list of each sequence (a list of (state list, symbol list) pair) from original data, as instructed to use for train model through PythonHMM. 
  It looks like this: </p>
  
  <pre><code>sequences = [
                   (['N','N'],['killer','clown']),
                   (['N','N'],['killer','problem']),
                   (['A','N'],['crazy','problem']),
                   (['A','N'],['crazy','clown']),
                   (['N','A','N'],['problem','crazy','clown']),
                   (['N','A','N'],['clown','crazy','killer'])
  ]
  </code></pre>
  
  <p>I am calling 'train' function of hmm (after imported hmm.py)</p>
  
  <pre><code>model_hmm = hmm.train(sequences)
  </code></pre>
  
  <p>then I am getting following error:</p>
  
  <hr>
  
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-41-24d7c607e58c&gt; in &lt;module&gt;()
  ----&gt; 1 model_hmm = hmm.train(sequences)
  
  /home/sk/hmm.py in train(sequences, delta, smoothing)
       95         for _, symbol_list in sequences:
       96             model.learn(symbol_list, smoothing)
  ---&gt; 97             new_likelihood += log(model.evaluate(symbol_list))
       98 
       99         new_likelihood /= length
  
  ValueError: math domain error
  </code></pre>
  
  <p>I could not able to figure out why this error comes, Is there any problem in passing sequences data to train function or something else??</p>
  
  <p>I also didn't find any example for training of HMM model for such type of problem. Please help me to resolve this error.</p>