Ticket #3726: sage-3726-part7.patch
| File sage-3726-part7.patch, 1.8 kB (added by was, 5 months ago) |
|---|
-
a/sage/stats/hmm/chmm.pyx
old new 596 596 exception on error 597 597 598 598 EXAMPLES: 599 We train a very simple model: 600 sage: m = hmm.GaussianHiddenMarkovModel([[1]], [(0,1)], [1]) 601 sage: m.baum_welch([1,1,1,1]) 599 602 600 NOTE: Training for models including silent states is not yet supported. 601 602 REFERENCES: 603 Rabiner, L.R.: "`A Tutorial on Hidden Markov Models and Selected 604 Applications in Speech Recognition"', Proceedings of the IEEE, 605 77, no 2, 1989, pp 257--285. 603 Notice that after training the mean in the emission parameters changes 604 form 0 to 1. 605 sage: m 606 Gaussian Hidden Markov Model with 1 States 607 Transition matrix: 608 [1.0] 609 Emission parameters: 610 [(1.0, 0.0001)] 611 Initial probabilities: [1.0] 606 612 """ 607 613 cdef ghmm_cmodel_baum_welch_context cs 608 614 609 615 cs.smo = self.m 610 616 cs.sqd = to_cseq(training_seqs) 617 cs.logp = <double*> safe_malloc(sizeof(double)) 611 618 cs.eps = log_likelihood_cutoff 612 619 cs.max_iter = max_iter 613 620 614 621 if ghmm_cmodel_baum_welch(&cs): 615 622 raise RuntimeError, "error running Baum-Welch algorithm" 616 #ghmm_cseq_free(&cs.sqd) 623 ghmm_cseq_free(&cs.sqd) 624 617 625 618 626 cdef ghmm_cseq* to_cseq(seq) except NULL: 619 627 """