public final class HmmUtils extends Object
Modifier and Type | Method and Description |
---|---|
static List<String> |
decodeStateSequence(HmmModel model,
int[] sequence,
boolean observed,
String defaultValue)
Decodes a given collection of state IDs into the corresponding state names
registered in a given model.
|
static int[] |
encodeStateSequence(HmmModel model,
Collection<String> sequence,
boolean observed,
int defaultValue)
Encodes a given collection of state names by the corresponding state IDs
registered in a given model.
|
static Vector |
getCumulativeInitialProbabilities(HmmModel model)
Compute the cumulative distribution of the initial hidden state
probabilities for the given HMM model.
|
static Matrix |
getCumulativeOutputMatrix(HmmModel model)
Compute the cumulative output probability matrix for the given HMM model.
|
static Matrix |
getCumulativeTransitionMatrix(HmmModel model)
Compute the cumulative transition probability matrix for the given HMM
model.
|
static void |
normalizeModel(HmmModel model)
Function used to normalize the probabilities of a given HMM model
|
static HmmModel |
truncateModel(HmmModel model,
double threshold)
Method to reduce the size of an HMMmodel by converting the models
DenseMatrix/DenseVectors to sparse implementations and setting every value
< threshold to 0
|
static void |
validate(HmmModel model)
Validates an HMM model set
|
public static Matrix getCumulativeTransitionMatrix(HmmModel model)
model
- The HMM model for which the cumulative transition matrix should be
computedpublic static Matrix getCumulativeOutputMatrix(HmmModel model)
model
- The HMM model for which the cumulative output matrix should be
computedpublic static Vector getCumulativeInitialProbabilities(HmmModel model)
model
- The HMM model for which the cumulative initial state probabilities
should be computedpublic static void validate(HmmModel model)
model
- model to sanity check.public static int[] encodeStateSequence(HmmModel model, Collection<String> sequence, boolean observed, int defaultValue)
model
- Model to provide the encoding forsequence
- Collection of state namesobserved
- If set, the sequence is encoded as a sequence of observed states,
else it is encoded as sequence of hidden statesdefaultValue
- The default value in case a state is not knownpublic static List<String> decodeStateSequence(HmmModel model, int[] sequence, boolean observed, String defaultValue)
model
- model to use for retrieving state namessequence
- int array of state IDsobserved
- If set, the sequence is encoded as a sequence of observed states,
else it is encoded as sequence of hidden statesdefaultValue
- The default value in case a state is not knownpublic static void normalizeModel(HmmModel model)
model
- model to normalizepublic static HmmModel truncateModel(HmmModel model, double threshold)
model
- model to truncatethreshold
- minimum value a model entry must have to be retained.Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.