| Home | Trees | Indices | Help |
|
|---|
|
|
A class for modeling and learning HMMs.
This class conveniently wraps the module level functions. Class objects hold 6
data members:
- num_states number of hidden states in the HMM
- num_symbols number of possible symbols in the observation
sequence
- precision precision of the numpy.array elements (defaults to
longdouble)
- prior The prior probability of starting in each state
(Nx1 array)
- transition_matrix The probability of transitioning between each state
(NxN matrix)
- emission_matrix The probability of each symbol in each state
(NxO matrix)
You can set the 3 matrix parameters as you wish, but make sure the shape of
the arrays matches num_states and num_symbols, as these are used internally
Typical usage of this class is to create an HMM with a set number of states
and external symbols, train the HMM using addEvidence(...), and then use
the sequenceProb(...) method to see how well a specific sequence matches
the trained HMM.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Creates a new HMMLearner object with the given number of internal states, and external symbols. calls self.reset(init_type=init_type) |
Resets the 3 arrays using the given initialization method.
Wipes out the old arrays. You can use this method to change the shape
of the arrays by first changing num_states and/or num_symbols, and then
calling this method.
Currently supported initialization methods:
uniform prior, transition, and emission probabilities are all
uniform (default)
|
Returns the probability that this HMM generated the given sequence. Uses the forward-backward algorithm. If given an array of sequences, returns a 1D array of probabilities. |
Updates this HMMs parameters given a new set of observed sequences using the Baum-Welch algorithm. newData can either be a single (1D) array of observed symbols, or a 2D matrix, each row of which is a seperate sequence. The Baum-Welch update is repeated 'iterations' times, or until the sum absolute change in each matrix is less than the given epsilon. If given multiple sequences, each sequence is used to update the parameters in order, and the sum absolute change is calculated once after all the sequences are processed. |
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Mar 5 00:49:16 2012 | http://epydoc.sourceforge.net |