Skip to content

Commit 2fe838c

Browse files
csytracylarsmans
authored andcommitted
FIX stability in HMMs
ValueErrors occur when there is 0 or nan in the covars of the data, or an infinity in stat['trans'].
1 parent 9a995db commit 2fe838c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sklearn/hmm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ def _accumulate_sufficient_statistics(self, stats, seq, framelogprob,
582582
_hmmc._compute_lneta(n_observations, n_components, fwdlattice,
583583
self._log_transmat, bwdlattice, framelogprob,
584584
lnP, lneta)
585-
stats["trans"] += np.exp(logsumexp(lneta, 0))
585+
stats['trans'] += np.exp(np.minimum(logsumexp(lneta, 0), 700))
586586

587587
def _do_mstep(self, stats, params):
588588
# Based on Huang, Acero, Hon, "Spoken Language Processing",

0 commit comments

Comments
 (0)