Expand description
Posterior (max-marginal) decoding for discrete HMMs.
Viterbi decoding returns the single jointly-most-probable state path
argmax_y P(y | o). Posterior decoding (also “maximum-marginal” or
“MPM — maximum posterior marginal” decoding) instead chooses, independently
at each time step, the state with the largest marginal posterior:
ŷ_t = argmax_j γ_t(j) , γ_t(j) = P(s_t = j | o_1…o_T)This minimises the expected number of individually-mislabelled positions
(per-symbol error / Hamming risk), whereas Viterbi minimises the
whole-sequence 0/1 error. The two can disagree, and the posterior path is
not guaranteed to be a legal path (it may traverse a zero-probability
transition), so we also expose posterior_path_is_feasible to check it.
The marginals γ come from log-space forward-backward; this module also
returns the expected number of correct labels under the model, which is
a useful confidence proxy: Σ_t max_j γ_t(j).
Structs§
- Posterior
Decode - Result of posterior (max-marginal) decoding.
Functions§
- posterior_
decode - Decode an observation sequence by maximum posterior marginal.
- posterior_
path_ is_ feasible - Whether a decoded path is feasible under the model — i.e. every visited
transition has positive probability and the initial state has positive
π.