Class ObservationClassifier
- 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.ObservationClassifier
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
HMMExponentialClassifier
,HMMGaussianClassifier
,HMMMultinomialClassifier
public abstract class ObservationClassifier extends TypedAtomicActor
This actor performs Maximum-Likelihood classification of the partially-observed Bayesian Network models. ClassifyObservations is designed to work with ExpectationMaximization, which provides the Maximum-Likelihood model parameters from which the observations are assumed to be drawn. The output is an integer array of labels, representing the maximum-likelihood hidden state sequence of the given model.
The user provides a set of parameter estimates as inputs to the model, and The mean is a double array input containing the mean estimate and sigma is a double array input containing standard deviation estimate of each mixture component. If the modelType is HMM, then an additional input, transitionMatrix is provided, which is an estimate of the transition matrix governing the Markovian process representing the hidden state evolution. The prior input is an estimate of the prior state distribution.
References
[1] Jordan, Michael I., et al. An introduction to variational methods for graphical models, Springer Netherlands, 1998.
[2] Bilmes, Jeff A. A gentle tutorial of the EM algorithm and its application to parameter estimation for Gaussian mixture and hidden Markov models. International Computer Science Institute 4.510 (1998): 126.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- See Also:
ParameterEstimator
,HMMGaussianClassifier
,HMMMultinomialClassifier
- 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
_classificationLength
length of the observation array to be classified.protected double
_likelihood
sequence likelihood assigned to current input.protected int
_nStates
number of hidden states.protected double[][]
_observations
observation array.protected double[]
_priors
prior hidden state distribution.protected double[][]
_transitionMatrixEstimate
transition matrix estimate for the markov chain model.TypedIOPort
input
An array of input symbols to be classified.TypedIOPort
likelihood
Likelihood of the input stream given the parameterized HMM.TypedIOPort
output
An array of state labels assigned to input symbols.PortParameter
prior
An array that defines priors on initial states.PortParameter
transitionMatrix
The transition probability matrix of the hidden markov chain.-
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 ObservationClassifier(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected int[]
classifyHMM(double[][] y, double[] prior, double[][] A)
Alpha-beta recursion.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.protected abstract double
emissionProbability(double[] y, int hiddenState)
Abstract class defining the emission probability computation of the latent variable.void
fire()
Consume the inputs and produce the outputs of the FFT filter.static int[]
gaussianClassifyMM(double[] y, double[] mu, double[] sigma, double[] prior)
Classify the incoming symbols into hidden states.-
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, preinitialize, 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, attributeChanged, 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, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
prior
public PortParameter prior
An array that defines priors on initial states.
-
transitionMatrix
public PortParameter transitionMatrix
The transition probability matrix of the hidden markov chain.
-
output
public TypedIOPort output
An array of state labels assigned to input symbols.
-
input
public TypedIOPort input
An array of input symbols to be classified.
-
likelihood
public TypedIOPort likelihood
Likelihood of the input stream given the parameterized HMM.
-
_classificationLength
protected int _classificationLength
length of the observation array to be classified.
-
_likelihood
protected double _likelihood
sequence likelihood assigned to current input.
-
_observations
protected double[][] _observations
observation array.
-
_nStates
protected int _nStates
number of hidden states.
-
_transitionMatrixEstimate
protected double[][] _transitionMatrixEstimate
transition matrix estimate for the markov chain model.
-
_priors
protected double[] _priors
prior hidden state distribution.
-
-
Constructor Detail
-
ObservationClassifier
public ObservationClassifier(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
-
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 classTypedAtomicActor
- 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
Consume the inputs and produce the outputs of the FFT filter.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If a runtime type error occurs.
-
classifyHMM
protected final int[] classifyHMM(double[][] y, double[] prior, double[][] A) throws IllegalActionException
Alpha-beta recursion.- Parameters:
y
- input sequenceprior
- prior guess vectorsA
- transition probability matrix- Returns:
- An array of assigned labels to observations
- Throws:
IllegalActionException
- If thrown while calculating the emmission probablity
-
gaussianClassifyMM
public static final int[] gaussianClassifyMM(double[] y, double[] mu, double[] sigma, double[] prior)
Classify the incoming symbols into hidden states.- Parameters:
y
- input arraymu
- mean array containing current mean estimates for hidden statessigma
- mean array containing current standard deviation estimates for hidden statesprior
- prior distribution estimates- Returns:
- labels of assigned states
-
emissionProbability
protected abstract double emissionProbability(double[] y, int hiddenState) throws IllegalActionException
Abstract class defining the emission probability computation of the latent variable.- Parameters:
y
- The y valueshiddenState
- The hidden state- Returns:
- the emission probability
- Throws:
IllegalActionException
- If there is a problem calculating the emission probability.
-
-