gov.sandia.cognition.learning.algorithm.hmm
Class AbstractBaumWelchAlgorithm<ObservationType,DataType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
          extended by gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm<ResultType>
              extended by gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner<DataType,HiddenMarkovModel<ObservationType>>
                  extended by gov.sandia.cognition.learning.algorithm.hmm.AbstractBaumWelchAlgorithm<ObservationType,DataType>
Type Parameters:
ObservationType - Type of Observations handled by the HMM.
DataType - Type of data (Collection of ObservationType, for instance) sent to the learn method.
All Implemented Interfaces:
AnytimeAlgorithm<HiddenMarkovModel<ObservationType>>, IterativeAlgorithm, MeasurablePerformanceAlgorithm, StoppableAlgorithm, AnytimeBatchLearner<DataType,HiddenMarkovModel<ObservationType>>, BatchLearner<DataType,HiddenMarkovModel<ObservationType>>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
BaumWelchAlgorithm

public abstract class AbstractBaumWelchAlgorithm<ObservationType,DataType>
extends AbstractAnytimeBatchLearner<DataType,HiddenMarkovModel<ObservationType>>
implements MeasurablePerformanceAlgorithm

Partial implementation of the Baum-Welch algorithm.

Since:
3.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Field Summary
static int DEFAULT_MAX_ITERATIONS
          Default maximum number of iterations, 100.
static boolean DEFAULT_REESTIMATE_INITIAL_PROBABILITY
          Default flag to re-estimate initial probabilities, true.
protected  BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> distributionLearner
          Learner for the Distribution Functions of the HMM.
protected  HiddenMarkovModel<ObservationType> initialGuess
          Initial guess for the iterations.
protected  double lastLogLikelihood
          Last Log Likelihood of the iterations
static String PERFORMANCE_NAME
          Name of the performance statistic, "Log Likelihood".
protected  boolean reestimateInitialProbabilities
          Flag to re-estimate the initial probability Vector.
protected  HiddenMarkovModel<ObservationType> result
          Result of the Baum-Welch Algorithm
 
Fields inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
data, keepGoing
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm
maxIterations
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
DEFAULT_ITERATION, iteration
 
Constructor Summary
AbstractBaumWelchAlgorithm(HiddenMarkovModel<ObservationType> initialGuess, BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> distributionLearner, boolean reestimateInitialProbabilities)
          Creates a new instance of AbstractBaumWelchAlgorithm
 
Method Summary
 AbstractBaumWelchAlgorithm<ObservationType,DataType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> getDistributionLearner()
          Getter for distributionLearner
 HiddenMarkovModel<ObservationType> getInitialGuess()
          Getter for initialGuess.
 double getLastLogLikelihood()
          Gets the log likelihood of the last completed step of the algorithm.
 NamedValue<Double> getPerformance()
          Gets the name-value pair that describes the current performance of the algorithm.
 boolean getReestimateInitialProbabilities()
          Getter for reestimateInitialProbabilities
 HiddenMarkovModel<ObservationType> getResult()
          Gets the current result of the algorithm.
 void setDistributionLearner(BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> distributionLearner)
          Setter for distributionLearner
 void setInitialGuess(HiddenMarkovModel<ObservationType> initialGuess)
          Setter for initialGuess.
 void setReestimateInitialProbabilities(boolean reestimateInitialProbabilities)
          Setter for reestimateInitialProbabilities
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
cleanupAlgorithm, getData, getKeepGoing, initializeAlgorithm, learn, setData, setKeepGoing, step, stop
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm
getMaxIterations, isResultValid, setMaxIterations
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.algorithm.AnytimeAlgorithm
getMaxIterations, setMaxIterations
 
Methods inherited from interface gov.sandia.cognition.algorithm.IterativeAlgorithm
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
 
Methods inherited from interface gov.sandia.cognition.algorithm.StoppableAlgorithm
isResultValid
 

Field Detail

DEFAULT_MAX_ITERATIONS

public static final int DEFAULT_MAX_ITERATIONS
Default maximum number of iterations, 100.

See Also:
Constant Field Values

DEFAULT_REESTIMATE_INITIAL_PROBABILITY

public static final boolean DEFAULT_REESTIMATE_INITIAL_PROBABILITY
Default flag to re-estimate initial probabilities, true.

See Also:
Constant Field Values

PERFORMANCE_NAME

public static final String PERFORMANCE_NAME
Name of the performance statistic, "Log Likelihood".

See Also:
Constant Field Values

distributionLearner

protected BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> distributionLearner
Learner for the Distribution Functions of the HMM.


result

protected HiddenMarkovModel<ObservationType> result
Result of the Baum-Welch Algorithm


initialGuess

protected HiddenMarkovModel<ObservationType> initialGuess
Initial guess for the iterations.


lastLogLikelihood

protected double lastLogLikelihood
Last Log Likelihood of the iterations


reestimateInitialProbabilities

protected boolean reestimateInitialProbabilities
Flag to re-estimate the initial probability Vector.

Constructor Detail

AbstractBaumWelchAlgorithm

public AbstractBaumWelchAlgorithm(HiddenMarkovModel<ObservationType> initialGuess,
                                  BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> distributionLearner,
                                  boolean reestimateInitialProbabilities)
Creates a new instance of AbstractBaumWelchAlgorithm

Parameters:
initialGuess - Initial guess for the iterations.
distributionLearner - Learner for the Distribution Functions of the HMM.
reestimateInitialProbabilities - Flag to re-estimate the initial probability Vector.
Method Detail

clone

public AbstractBaumWelchAlgorithm<ObservationType,DataType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractAnytimeBatchLearner<DataType,HiddenMarkovModel<ObservationType>>
Returns:
A clone of this object.

getPerformance

public NamedValue<Double> getPerformance()
Description copied from interface: MeasurablePerformanceAlgorithm
Gets the name-value pair that describes the current performance of the algorithm. For most algorithms, this is the value that they are attempting to optimize.

Specified by:
getPerformance in interface MeasurablePerformanceAlgorithm
Returns:
The name-value pair that describes the current performance of the algorithm.

getResult

public HiddenMarkovModel<ObservationType> getResult()
Description copied from interface: AnytimeAlgorithm
Gets the current result of the algorithm.

Specified by:
getResult in interface AnytimeAlgorithm<HiddenMarkovModel<ObservationType>>
Returns:
Current result of the algorithm.

getInitialGuess

public HiddenMarkovModel<ObservationType> getInitialGuess()
Getter for initialGuess.

Returns:
Initial guess for the iterations.

setInitialGuess

public void setInitialGuess(HiddenMarkovModel<ObservationType> initialGuess)
Setter for initialGuess.

Parameters:
initialGuess - Initial guess for the iterations.

getReestimateInitialProbabilities

public boolean getReestimateInitialProbabilities()
Getter for reestimateInitialProbabilities

Returns:
the reestimateInitialProbabilities Flag to re-estimate the initial probability Vector.

setReestimateInitialProbabilities

public void setReestimateInitialProbabilities(boolean reestimateInitialProbabilities)
Setter for reestimateInitialProbabilities

Parameters:
reestimateInitialProbabilities - Flag to re-estimate the initial probability Vector.

getDistributionLearner

public BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> getDistributionLearner()
Getter for distributionLearner

Returns:
Learner for the Distribution Functions of the HMM.

setDistributionLearner

public void setDistributionLearner(BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> distributionLearner)
Setter for distributionLearner

Parameters:
distributionLearner - Learner for the Distribution Functions of the HMM.

getLastLogLikelihood

public double getLastLogLikelihood()
Gets the log likelihood of the last completed step of the algorithm.

Returns:
The last log likelihood.