org.encog.ml.hmm
Class HiddenMarkovModel
- java.lang.Object
-
- org.encog.ml.BasicML
-
- org.encog.ml.hmm.HiddenMarkovModel
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, MLMethod, MLProperties, MLStateSequence
public class HiddenMarkovModel extends BasicML implements MLStateSequence, java.io.Serializable, java.lang.Cloneable
A Hidden Markov Model (HMM) is a Machine Learning Method that allows for predictions to be made about the hidden states and observations of a given system over time. A HMM can be thought of as a simple dynamic Bayesian network. The HMM is dynamic as it deals with changes that unfold over time. The Hidden Markov Model is made up of a number of states and observations. A simple example might be the state of the economy. There are three hidden states, such as bull market, bear market and level. We do not know which state we are currently in. However, there are observations that can be made such as interest rate and the level of the S&P500. The HMM learns what state we are in by seeing how the observations change over time. The HMM is only in one state at a given time. There is a percent probability that the HMM will move from one state to any of the other states. These probabilities are arranged in a grid, and are called the state transition probabilities. Observations can be discrete or continuous. These observations allow the HMM to predict state transitions. The HMM can handle single-value or multivariate observations. http://www.heatonresearch.com/wiki/Hidden_Markov_Model Rabiner, Juang, An introduction to Hidden Markov Models, IEEE ASSP Mag.,pp 4-16, June 1986. Baum, L. E.; Petrie, T. (1966). "Statistical Inference for Probabilistic Functions of Finite State Markov Chains" The Annals of Mathematical Statistics 37 (6): 1554-1563.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringTAG_COVARIANCEstatic java.lang.StringTAG_DIST_TYPEstatic java.lang.StringTAG_ITEMSstatic java.lang.StringTAG_MEANstatic java.lang.StringTAG_PIstatic java.lang.StringTAG_PROBABILITIESstatic java.lang.StringTAG_STATESstatic java.lang.StringTAG_TRANSITION
-
Constructor Summary
Constructors Constructor and Description HiddenMarkovModel(int states)Construct a discrete HMM with the specified number of states.HiddenMarkovModel(int theStates, int theItems)HiddenMarkovModel(int theStates, int[] theItems)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description HiddenMarkovModelclone()HiddenMarkovModelcloneStructure()StateDistributioncreateNewDistribution()int[]getItems()double[]getPi()doublegetPi(int i)intgetStateCount()StateDistributiongetStateDistribution(int i)int[]getStatesForSequence(MLDataSet seq)Get the sates for the given sequence.double[][]getTransitionProbability()doublegetTransitionProbability(int i, int j)booleanisContinuous()booleanisDiscrete()doublelnProbability(MLDataSet seq)doubleprobability(MLDataSet seq)Determine the probability of the specified sequence.doubleprobability(MLDataSet seq, int[] states)Determine the probability for the specified sequence and states.voidsetPi(double[] data)voidsetPi(int i, double value)voidsetStateDistribution(int i, StateDistribution dist)voidsetTransitionProbability(double[][] data)voidsetTransitionProbability(int i, int j, double value)voidupdateProperties()Update any objeccts when a property changes.-
Methods inherited from class org.encog.ml.BasicML
getProperties, getPropertyDouble, getPropertyLong, getPropertyString, setProperty, setProperty, setProperty
-
-
-
-
Field Detail
-
TAG_STATES
public static final java.lang.String TAG_STATES
- See Also:
- Constant Field Values
-
TAG_ITEMS
public static final java.lang.String TAG_ITEMS
- See Also:
- Constant Field Values
-
TAG_PI
public static final java.lang.String TAG_PI
- See Also:
- Constant Field Values
-
TAG_TRANSITION
public static final java.lang.String TAG_TRANSITION
- See Also:
- Constant Field Values
-
TAG_DIST_TYPE
public static final java.lang.String TAG_DIST_TYPE
- See Also:
- Constant Field Values
-
TAG_MEAN
public static final java.lang.String TAG_MEAN
- See Also:
- Constant Field Values
-
TAG_COVARIANCE
public static final java.lang.String TAG_COVARIANCE
- See Also:
- Constant Field Values
-
TAG_PROBABILITIES
public static final java.lang.String TAG_PROBABILITIES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HiddenMarkovModel
public HiddenMarkovModel(int states)
Construct a discrete HMM with the specified number of states.- Parameters:
states- The number of states.
-
HiddenMarkovModel
public HiddenMarkovModel(int theStates, int theItems)
-
HiddenMarkovModel
public HiddenMarkovModel(int theStates, int[] theItems)
-
-
Method Detail
-
clone
public HiddenMarkovModel clone() throws java.lang.CloneNotSupportedException
- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
cloneStructure
public HiddenMarkovModel cloneStructure()
-
createNewDistribution
public StateDistribution createNewDistribution()
-
getPi
public double getPi(int i)
-
getStateCount
public int getStateCount()
-
getStateDistribution
public StateDistribution getStateDistribution(int i)
-
getStatesForSequence
public int[] getStatesForSequence(MLDataSet seq)
Description copied from interface:MLStateSequenceGet the sates for the given sequence.- Specified by:
getStatesForSequencein interfaceMLStateSequence- Parameters:
seq- The sequence.- Returns:
- The states.
-
getTransitionProbability
public double getTransitionProbability(int i, int j)
-
isContinuous
public boolean isContinuous()
-
isDiscrete
public boolean isDiscrete()
-
lnProbability
public double lnProbability(MLDataSet seq)
-
probability
public double probability(MLDataSet seq)
Description copied from interface:MLStateSequenceDetermine the probability of the specified sequence.- Specified by:
probabilityin interfaceMLStateSequence- Parameters:
seq- The sequence.- Returns:
- The probability.
-
probability
public double probability(MLDataSet seq, int[] states)
Description copied from interface:MLStateSequenceDetermine the probability for the specified sequence and states.- Specified by:
probabilityin interfaceMLStateSequence- Parameters:
seq- The sequence.states- The states.- Returns:
- The probability.
-
setPi
public void setPi(int i, double value)
-
setStateDistribution
public void setStateDistribution(int i, StateDistribution dist)
-
setTransitionProbability
public void setTransitionProbability(int i, int j, double value)
-
updateProperties
public void updateProperties()
Description copied from interface:MLPropertiesUpdate any objeccts when a property changes.- Specified by:
updatePropertiesin interfaceMLProperties- Specified by:
updatePropertiesin classBasicML
-
getItems
public int[] getItems()
-
getPi
public double[] getPi()
-
getTransitionProbability
public double[][] getTransitionProbability()
-
setTransitionProbability
public void setTransitionProbability(double[][] data)
-
setPi
public void setPi(double[] data)
-
-
DMelt 3.0 © DataMelt by jWork.ORG