| | 770 | We compare using a non-default number of steps and non-default log likelihood cutoff: |
|---|
| | 771 | sage: h = hmm.DiscreteHiddenMarkovModel([[.1,.9],[.4,.6]], [[1/2]*2]*2, [1/2]*2) |
|---|
| | 772 | sage: h.baum_welch([1,1,1,1,1,0,1,1,1,1,1,0,0]) |
|---|
| | 773 | sage: h |
|---|
| | 774 | Discrete Hidden Markov Model with 2 States and 2 Emissions |
|---|
| | 775 | Transition matrix: |
|---|
| | 776 | [ 0.643888431046 0.356111568954] |
|---|
| | 777 | [0.00232031442167 0.997679685578] |
|---|
| | 778 | Emission matrix: |
|---|
| | 779 | [ 0.0 1.0] |
|---|
| | 780 | [0.296080269308 0.703919730692] |
|---|
| | 781 | Initial probabilities: [1.0, 3.6620347292312443e-20] |
|---|
| | 782 | sage: h = hmm.DiscreteHiddenMarkovModel([[.1,.9],[.4,.6]], [[1/2]*2]*2, [1/2]*2) |
|---|
| | 783 | sage: h.baum_welch([1,1,1,1,1,0,1,1,1,1,1,0,0], nsteps=1) |
|---|
| | 784 | sage: h |
|---|
| | 785 | Discrete Hidden Markov Model with 2 States and 2 Emissions |
|---|
| | 786 | Transition matrix: |
|---|
| | 787 | [0.1 0.9] |
|---|
| | 788 | [0.4 0.6] |
|---|
| | 789 | Emission matrix: |
|---|
| | 790 | [0.222426510432 0.777573489568] |
|---|
| | 791 | [0.234678486789 0.765321513211] |
|---|
| | 792 | Initial probabilities: [0.5, 0.5] |
|---|
| | 793 | sage: h = hmm.DiscreteHiddenMarkovModel([[.1,.9],[.4,.6]], [[1/2]*2]*2, [1/2]*2) |
|---|
| | 794 | sage: h.baum_welch([1,1,1,1,1,0,1,1,1,1,1,0,0], log_likelihood_cutoff=0.01) |
|---|
| | 795 | sage: h |
|---|
| | 796 | Discrete Hidden Markov Model with 2 States and 2 Emissions |
|---|
| | 797 | Transition matrix: |
|---|
| | 798 | [0.0999471960754 0.900052803925] |
|---|
| | 799 | [ 0.399248483887 0.600751516113] |
|---|
| | 800 | Emission matrix: |
|---|
| | 801 | [0.209328925617 0.790671074383] |
|---|
| | 802 | [ 0.24081056723 0.75918943277] |
|---|
| | 803 | Initial probabilities: [0.50877982192958637, 0.49122017807041363] |
|---|
| | 804 | |
|---|
| 802 | | if ghmm_dmodel_baum_welch(self.m, d): |
|---|
| 803 | | raise RuntimeError, "error running Baum-Welch algorithm" |
|---|
| | 837 | if nsteps or log_likelihood_cutoff: |
|---|
| | 838 | if nsteps is None: |
|---|
| | 839 | nsteps = GHMM_MAX_ITER_BW |
|---|
| | 840 | if log_likelihood_cutoff is None: |
|---|
| | 841 | log_likelihood_cutoff = GHMM_EPS_ITER_BW |
|---|
| | 842 | if ghmm_dmodel_baum_welch_nstep(self.m, d, nsteps, log_likelihood_cutoff): |
|---|
| | 843 | raise RuntimeError, "error running Baum-Welch algorithm" |
|---|
| | 844 | else: |
|---|
| | 845 | if ghmm_dmodel_baum_welch(self.m, d): |
|---|
| | 846 | raise RuntimeError, "error running Baum-Welch algorithm" |
|---|