logo
pub fn baum_welch<O: Debug + Eq + Hash + Ord, M: Model<O>>(
    hmm: &M,
    observations: &[O]
) -> (Array1<LogProb>, Array2<LogProb>, Array2<LogProb>, Array1<LogProb>)
Expand description

Execute one step of Baum-Welch algorithm to find the maximum likelihood estimate of the parameters of a HMM given a set of observed feature vector and return the estimated initial state distribution (π*), estimated transition matrix (A*), estimated emission probabilities matrix (B*) and end probabilities vector (if the model has declared an end state beforehand). This function doesn’t update the HMM parameters in the model and has been implemented for Discrete Emissions Models only. It return values as LogProb.

Arguments

  • hmm - the Model to run the baum-welch or expected maximization algorithm on. It has to be a Discrete Model with a Trainable trait implemented.
  • observations - a slice of observation values to use in the algorithm

Result

The resulting tuple (π*, A*, B*, E*) is the estimated initial probability table (P[s]), the estimated transitions probability table (P[[s, o]] is the entry for state s1 and other state s2), the estimated emission probability table (P[[s, s]] is the entry for state s and observation class o) and if we specify an end probability when building the model, E* is the estimated end probabilities. Otherwise, E* is a vector with size equal to initial probability and all values set to LogProb(1.0). The values in all outputs are shown as LogProb.

Type Parameters

  • O - the observation type (only discrete emissions)
  • M - type Model type