org.apache.mahout.classifier.sequencelearning.hmm
Class HmmAlgorithms

java.lang.Object
  extended by org.apache.mahout.classifier.sequencelearning.hmm.HmmAlgorithms

public final class HmmAlgorithms
extends Object

Class containing implementations of the three major HMM algorithms: forward, backward and Viterbi


Method Summary
static Matrix backwardAlgorithm(HmmModel model, int[] observations, boolean scaled)
          External function to compute a matrix of beta factors
static Matrix forwardAlgorithm(HmmModel model, int[] observations, boolean scaled)
          External function to compute a matrix of alpha factors
static int[] viterbiAlgorithm(HmmModel model, int[] observations, boolean scaled)
          Viterbi algorithm to compute the most likely hidden sequence for a given model and observed sequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

forwardAlgorithm

public static Matrix forwardAlgorithm(HmmModel model,
                                      int[] observations,
                                      boolean scaled)
External function to compute a matrix of alpha factors

Parameters:
model - model to run forward algorithm for.
observations - observation sequence to train on.
scaled - Should log-scaled beta factors be computed?
Returns:
matrix of alpha factors.

backwardAlgorithm

public static Matrix backwardAlgorithm(HmmModel model,
                                       int[] observations,
                                       boolean scaled)
External function to compute a matrix of beta factors

Parameters:
model - model to use for estimation.
observations - observation sequence seen.
scaled - Set to true if log-scaled beta factors should be computed.
Returns:
beta factors based on the model and observation sequence.

viterbiAlgorithm

public static int[] viterbiAlgorithm(HmmModel model,
                                     int[] observations,
                                     boolean scaled)
Viterbi algorithm to compute the most likely hidden sequence for a given model and observed sequence

Parameters:
model - HmmModel for which the Viterbi path should be computed
observations - Sequence of observations
scaled - Use log-scaled computations, this requires higher computational effort but is numerically more stable for large observation sequences
Returns:
nrOfObservations 1D int array containing the most likely hidden sequence


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.