Class ViterbiUtils


  • public final class ViterbiUtils
    extends java.lang.Object
    Viterbi Utilities for forward backward passes and his famous decoding algorithm for hidden markov models.
    Author:
    thomas.jungblut
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static de.jungblut.math.DoubleMatrix decode​(de.jungblut.math.DoubleMatrix weights, de.jungblut.math.DoubleMatrix features, de.jungblut.math.DoubleMatrix featuresPerState, int classes)
      Do a decoding pass on the given HMM weights, the features to decode and how many classes to predict.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • decode

        public static de.jungblut.math.DoubleMatrix decode​(de.jungblut.math.DoubleMatrix weights,
                                                           de.jungblut.math.DoubleMatrix features,
                                                           de.jungblut.math.DoubleMatrix featuresPerState,
                                                           int classes)
        Do a decoding pass on the given HMM weights, the features to decode and how many classes to predict. The output will contain a vector that contains a 1 at the index of the predicted label.
        Parameters:
        weights - the HMM weights.
        features - the features to predict on.
        featuresPerState - the matrix containing the feature vectors, precomputed for each possible state in classes. The layout is that the same feature was computed n-times, so class 0 first, class 1 next and so on and this is layed out in rows (Feature 1 | class 0, Feature 1 | class 1 ...). Feature 0 is only contained once, because it only had class zero as previous class.
        classes - how many classes? 2 if binary.
        Returns:
        a n x m matrix where n is the number of featurevectors and m is the number of classes (in binary prediction this is just 1, 0 and 1 are the predicted labels at index 0 then).