HMMs with Gaussian distribution as emissions.
Methods
|
|
|
|
__init__
|
__init__ (
self,
emissionDomain,
distribution,
cmodel,
)
|
|
__str__
|
__str__ ( self )
|
|
backward
|
backward (
self,
emissionSequence,
scalingVector,
)
Result: the (N x T)-matrix containing the backward-variables
Exceptions
|
|
TypeError, "EmissionSequence required, got " + str( emissionSequence.__class__.__name__ )
|
|
|
baumWelch
|
baumWelch (
self,
trainingSequences,
nrSteps,
loglikelihoodCutoff,
)
Reestimate the model parameters given the training_sequences.
Perform at most nr_steps until the improvement in likelihood
is below likelihood_cutoff training_sequences can either be a SequenceSet or a Sequence
Result: Final loglikelihood
Exceptions
|
|
TypeError, "baumWelch requires a SequenceSet or EmissionSequence object."
|
|
|
baumWelchDelete
|
baumWelchDelete ( self )
Delete the necessary temporary variables for Baum-Welch-reestimation
|
|
baumWelchSetup
|
baumWelchSetup (
self,
trainingSequences,
nrSteps,
)
Setup necessary temporary variables for Baum-Welch-reestimation.
Use baum_welch_setup and baum_welch_step if you want more control
over the training, compute diagnostics or do noise-insertion training_sequences can either be a SequenceSet or a Sequence
Return: a C-array of type smosqd_t
|
|
baumWelchStep
|
baumWelchStep (
self,
nrSteps,
loglikelihoodCutoff,
)
Compute one iteration of Baum Welch estimation.
Use baum_welch_setup and baum_welch_step if you want more control
over the training, compute diagnostics or do noise-insertion training_sequences can either be a SequenceSet or a Sequence
|
|
forward
|
forward ( self, emissionSequence )
Result: the (N x T)-matrix containing the forward-variables
and the scaling vector
Exceptions
|
|
TypeError, "EmissionSequence required, got " + str( emissionSequence.__class__.__name__ )
|
|
|
getEmission
|
getEmission ( self, i )
Return (mu, sigma^2)
|
|
getMixtureFix
|
getMixtureFix ( self, state )
|
|
getStateFix
|
getStateFix ( self, state )
|
|
getTransition
|
getTransition (
self,
i,
j,
)
Returns the probability of the transition from state i to state j.
Raises IndexError if the transition is not allowed
|
|
loglikelihoods
|
loglikelihoods ( self, emissionSequences )
Compute a vector ( log( P[s| model]) )_{s} of log-likelihoods of the
individual emission_sequences using the forward algorithm emission_sequences is of type SequenceSet
Result: log( P[emissionSequences| model]) of type float
(numarray) vector of floats
Exceptions
|
|
TypeError, "EmissionSequence or SequenceSet required, got " + str( emissionSequences.__class__.__name__ )
|
|
|
normalize
|
normalize ( self )
Normalize transition probs, emission probs (if applicable)
|
|
pathPosterior
|
pathPosterior (
self,
sequence,
path,
)
Returns the log posterior probability for path having generated sequence .
CAVEAT: statePosterior needs to calculate the complete forward and backward matrices. If
you are interested in multiple paths it would be more efficient to use the posterior function
directly and not multiple calls to pathPosterior
|
|
posterior
|
posterior ( self, sequence )
Posterior distribution matrix for sequence .
|
|
sample
|
sample (
self,
seqNr,
T,
seed=-1,
)
Sample emission sequences
different function signatures require overloading of parent class methods
|
|
sampleSingle
|
sampleSingle (
self,
T,
seed=-1,
)
Sample a single emission sequence of length at most T.
Returns a Sequence object.
|
|
setEmission
|
setEmission (
self,
i,
(,
)
Set the emission distributionParameters for state i
|
|
setMixtureFix
|
setMixtureFix (
self,
state,
flags,
)
|
|
setStateFix
|
setStateFix (
self,
state,
flag,
)
|
|
setTransition
|
setTransition (
self,
i,
j,
prob,
)
Accessor function for the transition a_ij
|
|
statePosterior
|
statePosterior (
self,
sequence,
state,
time,
)
Return the log posterior probability for being at state at time time in sequence .
CAVEAT: statePosterior needs to calculate the complete forward and backward matrices. If
you are interested in multiple states it would be more efficient to use the posterior function
directly and not multiple calls to statePosterior
|
|
toMatrices
|
toMatrices ( self )
Return the parameters in matrix form.
|
|
viterbi
|
viterbi ( self, emissionSequences )
Compute the Viterbi-path for each sequence in emissionSequences
emission_sequences can either be a SequenceSet or an EmissionSequence
Result: [q_0, ..., q_T] the viterbi-path of emission_sequences is an emmissionSequence
object, [[q_0^0, ..., q_T^0], ..., [q_0^k, ..., q_T^k]} for a k-sequence
SequenceSet
Exceptions
|
|
TypeError, "EmissionSequence or SequenceSet required, got " + str( emissionSequences.__class__.__name__ )
|
|