Package org.ptolemy.machineLearning.hsmm
Class HSMMTimeAwareMultinomialEstimator
- 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
-
- org.ptolemy.machineLearning.hmm.ParameterEstimator
-
- org.ptolemy.machineLearning.hsmm.HSMMParameterEstimator
-
- org.ptolemy.machineLearning.hsmm.HSMMMultinomialEstimator
-
- org.ptolemy.machineLearning.hsmm.HSMMTimeAwareMultinomialEstimator
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
HSMMTimeAwareMultinomialEstimatorWithCodegen
public class HSMMTimeAwareMultinomialEstimator extends HSMMMultinomialEstimator
A parameter estimator for a Hidden Semi-Markov Model with Multinomial Emissions. The transition probability matrix is estimated on an hourly basis.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (ilgea)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]
_hourOfDay
hour of day for input observations.protected double[][][]
At
Time-dependent transition probability matrix.protected double[][][]
Atlearned
The learned transition probability matrix: before completion strategy is applied.TypedIOPort
empiricalStartTimes
Array of estimated probability transition matrices for each hour.protected static java.lang.String
FORCE_SELF
Completion strategy for A set to forcing a self-transition.protected static java.lang.String
FORCE_ZERO
Completion strategy for A set to forcing a transition to state 0.protected java.util.Set<int[]>
incompleteCategories
Hour categories for which At has not enough information.protected static java.lang.String
INTERPOLATE
Completion strategy for A set to interpolation, that is, a uniform distribuition on all states that have Hamming distance <= 1 to the binary representation of the source state.protected static java.lang.String
NO_ACTION
No completion strategy.protected static int
NUM_CATEGORIES
Number of partitions in the probability transition matrix.protected static java.lang.String
SELF_AND_ZERO
Completion strategy for A set to self and zero transitions with equal probability.TypedIOPort
timestamps
Array of observation timestamps as UNIX timestamps.Parameter
transitionMatrixEstimationMethod
Transition Matrix partitioning options.-
Fields inherited from class org.ptolemy.machineLearning.hsmm.HSMMMultinomialEstimator
_B, _nCategories, clusters, emissionEstimates, nCategories, observationDimension, observationProbabilities, prior_new
-
Fields inherited from class org.ptolemy.machineLearning.hsmm.HSMMParameterEstimator
_D, _D0, _dPriors0, _durationPriors, _etaDimension, _likelihoodHistory, _maxDuration, clusterAssignments, D_new, durationEstimates, durationPriorEstimates, durationProbabilities, maxStateDuration, priorDurationDistribution
-
Fields inherited from class org.ptolemy.machineLearning.hmm.ParameterEstimator
_A0, _likelihood, _likelihoodThreshold, _nIterations, _nStates, _obsDimension, _observations, _priorIn, _priors, _randomize, _transitionMatrix, A0, input, likelihood, likelihoodOut, likelihoodThreshold, maxIterations, newEstimates, nStates, priorDistribution, priorEstimates, randomizeGuessVectors, transitionMatrix
-
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.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description HSMMTimeAwareMultinomialEstimator(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 void
_calculateTransitionScheme(java.lang.String method, int category)
Compute missing transition probabilities in the hourly transition matrix estimates.protected void
_learnAt()
Learn the transition probability matrix for each hour, from timestamped data.void
_sendEmpiricalMatrix()
Send the learned matrix to the output.void
attributeChanged(Attribute attribute)
React to a change in an attribute.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Do nothing.-
Methods inherited from class org.ptolemy.machineLearning.hsmm.HSMMMultinomialEstimator
_checkForConvergence, _initializeEMParameters, _iterateEM, _updateEstimates, durationProbability, emissionProbability
-
Methods inherited from class org.ptolemy.machineLearning.hsmm.HSMMParameterEstimator
_EMParameterEstimation, _initializeArrays, HSMMAlphaBetaRecursion, preinitialize
-
Methods inherited from class org.ptolemy.machineLearning.hmm.ParameterEstimator
HMMAlphaBetaRecursion
-
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, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, 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, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
timestamps
public TypedIOPort timestamps
Array of observation timestamps as UNIX timestamps.
-
transitionMatrixEstimationMethod
public Parameter transitionMatrixEstimationMethod
Transition Matrix partitioning options. Force self transition asserts a self transition with probability 1 if no information has been learned for the state. Interpolate: Assigns uniform probabilities to any state that has Hamming distance less than two to the current state.
-
empiricalStartTimes
public TypedIOPort empiricalStartTimes
Array of estimated probability transition matrices for each hour.
-
NUM_CATEGORIES
protected static final int NUM_CATEGORIES
Number of partitions in the probability transition matrix.- See Also:
- Constant Field Values
-
INTERPOLATE
protected static final java.lang.String INTERPOLATE
Completion strategy for A set to interpolation, that is, a uniform distribuition on all states that have Hamming distance <= 1 to the binary representation of the source state.- See Also:
- Constant Field Values
-
FORCE_SELF
protected static final java.lang.String FORCE_SELF
Completion strategy for A set to forcing a self-transition.- See Also:
- Constant Field Values
-
FORCE_ZERO
protected static final java.lang.String FORCE_ZERO
Completion strategy for A set to forcing a transition to state 0.- See Also:
- Constant Field Values
-
NO_ACTION
protected static final java.lang.String NO_ACTION
No completion strategy.- See Also:
- Constant Field Values
-
SELF_AND_ZERO
protected static final java.lang.String SELF_AND_ZERO
Completion strategy for A set to self and zero transitions with equal probability.- See Also:
- Constant Field Values
-
At
protected double[][][] At
Time-dependent transition probability matrix.
-
Atlearned
protected double[][][] Atlearned
The learned transition probability matrix: before completion strategy is applied.
-
incompleteCategories
protected java.util.Set<int[]> incompleteCategories
Hour categories for which At has not enough information.
-
_hourOfDay
protected int[] _hourOfDay
hour of day for input observations.
-
-
Constructor Detail
-
HSMMTimeAwareMultinomialEstimator
public HSMMTimeAwareMultinomialEstimator(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:NamedObj
React to a change in an attribute. This method is called by a contained attribute when its value changes. In this base class, the method does nothing. In derived classes, this method may throw an exception, indicating that the new attribute value is invalid. It is up to the caller to restore the attribute to a valid value if an exception is thrown.- Overrides:
attributeChanged
in classHSMMMultinomialEstimator
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the change is not acceptable to this container (not thrown in this base class).
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Description copied from class:TypedAtomicActor
Clone the actor into the specified workspace.- Overrides:
clone
in classHSMMMultinomialEstimator
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Description copied from class:AtomicActor
Do nothing. Derived classes override this method to define their primary run-time action.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classHSMMMultinomialEstimator
- Throws:
IllegalActionException
- Not thrown in this base class.
-
_sendEmpiricalMatrix
public void _sendEmpiricalMatrix() throws NoRoomException, IllegalActionException
Send the learned matrix to the output.
-
_learnAt
protected void _learnAt()
Learn the transition probability matrix for each hour, from timestamped data.
-
_calculateTransitionScheme
protected void _calculateTransitionScheme(java.lang.String method, int category)
Compute missing transition probabilities in the hourly transition matrix estimates.- Parameters:
method
- Completion strategycategory
- Source category
-
-