public final class HMM extends AbstractClassifier implements org.apache.hadoop.io.Writable
| Constructor and Description |
|---|
HMM() |
HMM(int numVisibleStates,
int numHiddenStates) |
| Modifier and Type | Method and Description |
|---|---|
de.jungblut.math.DoubleMatrix |
decode(de.jungblut.math.DoubleVector[] observationSequence,
de.jungblut.math.DoubleVector[] featuresPerHiddenState)
Decodes the given observation sequence (features) with the current HMM.
|
double |
estimateLikelihood(de.jungblut.math.DoubleVector[] observationSequence)
Likelihood estimation on the current HMM.
|
de.jungblut.math.DoubleMatrix |
getEmissionProbabilitiyMatrix() |
de.jungblut.math.DoubleVector |
getHiddenPriorProbability() |
int |
getNumHiddenStates() |
int |
getNumVisibleStates() |
de.jungblut.math.DoubleMatrix |
getTransitionProbabilityMatrix() |
de.jungblut.math.DoubleVector |
predict(de.jungblut.math.DoubleVector features)
Classifies the given features.
|
de.jungblut.math.DoubleVector |
predict(de.jungblut.math.DoubleVector features,
de.jungblut.math.DoubleVector previousOutcome) |
void |
readFields(DataInput in) |
void |
train(de.jungblut.math.DoubleVector[] features,
de.jungblut.math.DoubleVector[] outcome)
Trains this classifier with the given features and the outcome.
|
void |
trainSupervised(de.jungblut.math.DoubleVector[] features,
de.jungblut.math.DoubleVector[] outcome)
Trains the current models parameters by executing a forwad pass over the
given observations (hidden and visible states).
|
void |
trainUnsupervised(de.jungblut.math.DoubleVector[] features,
double epsilon,
int maxIterations,
boolean verbose)
Trains the current models parameters by executing a baum-welch expectation
maximization algorithm.
|
void |
write(DataOutput out) |
trainextractPredictedClass, extractPredictedClass, predictedClass, predictedClass, predictProbabilityclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasClassifier, extractPredictedClass, extractPredictedClass, predictedClass, predictedClass, predictProbabilitypublic double estimateLikelihood(de.jungblut.math.DoubleVector[] observationSequence)
observationSequence - the given sequence of observations (features).public de.jungblut.math.DoubleMatrix decode(de.jungblut.math.DoubleVector[] observationSequence,
de.jungblut.math.DoubleVector[] featuresPerHiddenState)
ViterbiUtils
decode(DoubleVector[], DoubleVector[]).observationSequence - the given sequence of features.public void trainUnsupervised(de.jungblut.math.DoubleVector[] features,
double epsilon,
int maxIterations,
boolean verbose)
features - the visible state activations (the vector will be traversed
for non-zero entries, so the value actually doesn't matter).epsilon - the absolute difference in the train model to the previous.
If smaller than given value the iterations are stopped and the
training finishes.maxIterations - if the epsilon threshold is never reached, the maximum
iterations usually applies by stopping computation after given
number of iterations.verbose - when set to true it will print information about the
expectimax values per iteration.public void trainSupervised(de.jungblut.math.DoubleVector[] features,
de.jungblut.math.DoubleVector[] outcome)
features - the visible state activations (the vector will be traversed
for non-zero entries, so the value actually doesn't matter).outcome - the outcome that was assigned to the given features. This
can be in the binary case a single element vector (0d or 1d), or
in the multi-class case a vector which index denotes the class
(from zero to numHiddenStates, activation is again 0d or 1d). Note
that in the multi-class case just a single state can be turned on,
so the classes are mutual exclusive.public void train(de.jungblut.math.DoubleVector[] features,
de.jungblut.math.DoubleVector[] outcome)
Classifiertrain in interface Classifiertrain in class AbstractClassifieroutcome - the outcome must have classes labeled as doubles. E.G. in
the binary case you have a single element and decide between 0d
and 1d. In higher dimensional cases you have each of these single
elements mapped to a dimension.public de.jungblut.math.DoubleVector predict(de.jungblut.math.DoubleVector features)
Predictorpublic de.jungblut.math.DoubleVector predict(de.jungblut.math.DoubleVector features,
de.jungblut.math.DoubleVector previousOutcome)
public int getNumHiddenStates()
public int getNumVisibleStates()
public de.jungblut.math.DoubleMatrix getEmissionProbabilitiyMatrix()
public de.jungblut.math.DoubleVector getHiddenPriorProbability()
public de.jungblut.math.DoubleMatrix getTransitionProbabilityMatrix()
public void write(DataOutput out) throws IOException
write in interface org.apache.hadoop.io.WritableIOExceptionpublic void readFields(DataInput in) throws IOException
readFields in interface org.apache.hadoop.io.WritableIOExceptionCopyright © 2016. All rights reserved.