gov.sandia.cognition.statistics.distribution
Class MixtureOfGaussians.EMLearner

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<Collection<? extends Vector>,MixtureOfGaussians.PDF>
                  extended by gov.sandia.cognition.statistics.distribution.MixtureOfGaussians.EMLearner
All Implemented Interfaces:
AnytimeAlgorithm<MixtureOfGaussians.PDF>, IterativeAlgorithm, MeasurablePerformanceAlgorithm, StoppableAlgorithm, AnytimeBatchLearner<Collection<? extends Vector>,MixtureOfGaussians.PDF>, BatchLearner<Collection<? extends Vector>,MixtureOfGaussians.PDF>, DistributionEstimator<Vector,MixtureOfGaussians.PDF>, CloneableSerializable, Randomized, Serializable, Cloneable
Enclosing class:
MixtureOfGaussians

@PublicationReference(author="Jaakkola",
                      title="Estimating mixtures: the EM-algorithm",
                      type=Misc,
                      year=2007,
                      url="http://courses.csail.mit.edu/6.867/lectures/notes-em2.pdf")
public static class MixtureOfGaussians.EMLearner
extends AbstractAnytimeBatchLearner<Collection<? extends Vector>,MixtureOfGaussians.PDF>
implements Randomized, DistributionEstimator<Vector,MixtureOfGaussians.PDF>, MeasurablePerformanceAlgorithm

An Expectation-Maximization based "soft" assignment learner.

See Also:
Serialized Form

Field Summary
static int DEFAULT_MAX_ITERATIONS
          Default max iterations, 100.
static double DEFAULT_TOLERANCE
          Default tolerance, 1.0E-5.
static String PERFORMANCE_NAME
          Name of the performance measurement, "Assignment Change".
protected  Random random
          Random number generator.
 
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
MixtureOfGaussians.EMLearner(int distributionCount, MultivariateGaussian.WeightedMaximumLikelihoodEstimator learner, Random random)
          Creates a new instance of EMLearner
MixtureOfGaussians.EMLearner(int distributionCount, Random random)
          Creates a new instance of EMLearner
MixtureOfGaussians.EMLearner(Random random)
          Creates a new instance of EMLearner
 
Method Summary
protected  void cleanupAlgorithm()
          Called to clean up the learning algorithm's state after learning has finished.
 double getAssignmentChanged()
          Gets the total assignment change from the last completed step of the algorithm.
 NamedValue<Double> getPerformance()
          Gets the name-value pair that describes the current performance of the algorithm.
 Random getRandom()
          Gets the random number generator used by this object.
 MixtureOfGaussians.PDF getResult()
          Gets the current result of the algorithm.
 double getTolerance()
          Getter for tolerance
protected  boolean initializeAlgorithm()
          Called to initialize the learning algorithm's state based on the data that is stored in the data field.
 void setRandom(Random random)
          Sets the random number generator used by this object.
 void setTolerance(double tolerance)
          Setter for tolerance
protected  boolean step()
          Called to take a single step of the learning algorithm.
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
clone, getData, getKeepGoing, learn, setData, setKeepGoing, 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.learning.algorithm.BatchLearner
learn
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 
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

PERFORMANCE_NAME

public static final String PERFORMANCE_NAME
Name of the performance measurement, "Assignment Change".

See Also:
Constant Field Values

DEFAULT_MAX_ITERATIONS

public static final int DEFAULT_MAX_ITERATIONS
Default max iterations, 100.

See Also:
Constant Field Values

DEFAULT_TOLERANCE

public static final double DEFAULT_TOLERANCE
Default tolerance, 1.0E-5.

See Also:
Constant Field Values

random

protected Random random
Random number generator.

Constructor Detail

MixtureOfGaussians.EMLearner

public MixtureOfGaussians.EMLearner(Random random)
Creates a new instance of EMLearner

Parameters:
random - Random number generator

MixtureOfGaussians.EMLearner

public MixtureOfGaussians.EMLearner(int distributionCount,
                                    Random random)
Creates a new instance of EMLearner

Parameters:
distributionCount - Number of distributions in the mixture
random - Random number generator

MixtureOfGaussians.EMLearner

public MixtureOfGaussians.EMLearner(int distributionCount,
                                    MultivariateGaussian.WeightedMaximumLikelihoodEstimator learner,
                                    Random random)
Creates a new instance of EMLearner

Parameters:
distributionCount - Number of distributions in the mixture
learner - Learner used to reestimate the components
random - Random number generator
Method Detail

initializeAlgorithm

protected boolean initializeAlgorithm()
Description copied from class: AbstractAnytimeBatchLearner
Called to initialize the learning algorithm's state based on the data that is stored in the data field. The return value indicates if the algorithm can be run or not based on the initialization.

Specified by:
initializeAlgorithm in class AbstractAnytimeBatchLearner<Collection<? extends Vector>,MixtureOfGaussians.PDF>
Returns:
True if the learning algorithm can be run and false if it cannot.

step

protected boolean step()
Description copied from class: AbstractAnytimeBatchLearner
Called to take a single step of the learning algorithm.

Specified by:
step in class AbstractAnytimeBatchLearner<Collection<? extends Vector>,MixtureOfGaussians.PDF>
Returns:
True if another step can be taken and false it the algorithm should halt.

cleanupAlgorithm

protected void cleanupAlgorithm()
Description copied from class: AbstractAnytimeBatchLearner
Called to clean up the learning algorithm's state after learning has finished.

Specified by:
cleanupAlgorithm in class AbstractAnytimeBatchLearner<Collection<? extends Vector>,MixtureOfGaussians.PDF>

getResult

public MixtureOfGaussians.PDF getResult()
Description copied from interface: AnytimeAlgorithm
Gets the current result of the algorithm.

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

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.

getTolerance

public double getTolerance()
Getter for tolerance

Returns:
Tolerance before stopping, must be greater than or equal to 0

setTolerance

public void setTolerance(double tolerance)
Setter for tolerance

Parameters:
tolerance - Tolerance before stopping, must be greater than or equal to 0

getRandom

public Random getRandom()
Description copied from interface: Randomized
Gets the random number generator used by this object.

Specified by:
getRandom in interface Randomized
Returns:
The random number generator used by this object.

setRandom

public void setRandom(Random random)
Description copied from interface: Randomized
Sets the random number generator used by this object.

Specified by:
setRandom in interface Randomized
Parameters:
random - The random number generator for this object to use.

getAssignmentChanged

public double getAssignmentChanged()
Gets the total assignment change from the last completed step of the algorithm.

Returns:
The assignment changed from the last completed step.