Class HMMGaussianEstimator
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.actor.lib.aspect.AtomicCommunicationAspect
-
- org.ptolemy.machineLearning.hmmAOM.ParameterEstimator
-
- org.ptolemy.machineLearning.hmmAOM.HMMGaussianEstimator
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,CommunicationAspect
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Decorator
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class HMMGaussianEstimator extends ParameterEstimator
This actor implements a parameter estimator for Hidden Markov Models with Gaussian Emissions. The base class ParameterEstimator performs the parameter estimation and the HMMGaussianEstimator class contains density-specific methods for Gaussian emission calculations and produces the relevant estimates at its output ports.
The output ports for a Gaussian HMM model are the mean and the standardDeviation vectors of the possible hidden states in addition to the HMM parameters independent from the emission density: transitionMatrix . T he mean is a double array output containing the mean estimates and sigma is a double array output containing standard deviation estimates of each mixture component. If the modelType is HMM, then an additional output, transitionMatrix is provided, which is an estimate of the transition matrix governing the Markovian process representing the hidden state evolution. If the modelType is MM, this port outputs a double array with the prior probability estimates of the mixture components.
The user-defined parameters are initial guesses for the model parameters, given by m0, the mean vector guess, s0, the standard deviation vector guess, prior, the prior state distribution guess, A0, the transition matrix guess ( only for HMM). iterations is the number of EM iterations allowed until convergence. If, during iteration, the conditional log-likelihood of the observed sequence given the parameter estimates converges to a value within likelihoodThreshold, the parameter estimation stops iterating and delivers the parameter estimates.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- Pt.AcceptedRating:
- Pt.ProposedRating:
- Red (ilgea)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.ptolemy.machineLearning.hmmAOM.ParameterEstimator
ParameterEstimator.BusAttributes
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description TypedIOPort
mean
The mean.Parameter
meanVectorGuess
The mean vector guess.TypedIOPort
standardDeviation
The standard deviation.Parameter
standardDeviationGuess
The standard deviation guess.-
Fields inherited from class org.ptolemy.machineLearning.hmmAOM.ParameterEstimator
_A0, _batchSize, _likelihood, _likelihoodThreshold, _nIterations, _nStates, _observations, _observedTokens, _priorIn, _priors, _randomize, _transitionMatrix, A0, batchSize, input, likelihoodThreshold, maxIterations, nStates, priorDistribution, priorEstimates, randomizeGuessVectors, serviceTimeMultiplicationFactor, transitionMatrix
-
Fields inherited from class ptolemy.actor.lib.aspect.AtomicCommunicationAspect
_parameters, _tokenCount
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.CommunicationAspect
decoratorHighlightColorName
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description HMMGaussianEstimator(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_checkForConvergence(int iterations)
protected void
_initializeEMParameters()
protected void
_iterateEM()
protected void
_updateEstimates()
void
attributeChanged(Attribute attribute)
If the attribute is serviceTime, then ensure that the value is non-negative.java.lang.Object
clone(Workspace workspace)
Clone this actor into the specified workspace.protected double
emissionProbability(double y, int hiddenState)
void
fire()
Send first token in the queue to the target receiver.-
Methods inherited from class org.ptolemy.machineLearning.hmmAOM.ParameterEstimator
_EMParameterEstimation, _initializeArrays, _scheduleRefire, createDecoratorAttributes, createIntermediateReceiver, HMMAlphaBetaRecursion, HMMAlphaBetaRecursionNonNormalized, initialize, postfire, reset, sendToken, setContainer
-
Methods inherited from class ptolemy.actor.lib.aspect.AtomicCommunicationAspect
_sendToReceiver, decoratedObjects, isGlobalDecorator, registerListener, sendCommunicationEvent
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
mean
public TypedIOPort mean
The mean. A double array output
-
standardDeviation
public TypedIOPort standardDeviation
The standard deviation. A double array output
-
meanVectorGuess
public Parameter meanVectorGuess
The mean vector guess. A double array with initial values {0.0, 4.0}.
-
standardDeviationGuess
public Parameter standardDeviationGuess
The standard deviation guess. A double array with initial values (1.0, 1.0}.
-
-
Constructor Detail
-
HMMGaussianEstimator
public HMMGaussianEstimator(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an actor with the given container and name.- Parameters:
container
- The container.name
- The name of this actor- Throws:
IllegalActionException
- If the actor cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
Description copied from class:ParameterEstimator
If the attribute is serviceTime, then ensure that the value is non-negative.- Overrides:
attributeChanged
in classParameterEstimator
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the service time is negative.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Description copied from class:ParameterEstimator
Clone this actor into the specified workspace. The new actor is not added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container. A container must be set before much can be done with this actor.- Overrides:
clone
in classParameterEstimator
- Parameters:
workspace
- The workspace for the cloned object.- Returns:
- A new Bus.
- Throws:
java.lang.CloneNotSupportedException
- If cloned ports cannot have as their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Description copied from class:ParameterEstimator
Send first token in the queue to the target receiver.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classParameterEstimator
- Throws:
IllegalActionException
- Not thrown in this base class.
-
emissionProbability
protected double emissionProbability(double y, int hiddenState)
- Specified by:
emissionProbability
in classParameterEstimator
-
_checkForConvergence
protected boolean _checkForConvergence(int iterations)
- Specified by:
_checkForConvergence
in classParameterEstimator
-
_initializeEMParameters
protected void _initializeEMParameters()
- Specified by:
_initializeEMParameters
in classParameterEstimator
-
_iterateEM
protected void _iterateEM()
- Specified by:
_iterateEM
in classParameterEstimator
-
_updateEstimates
protected void _updateEstimates()
- Specified by:
_updateEstimates
in classParameterEstimator
-
-