|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--ostore.oil.HMM
Hidden Markov Model: a statistical tool which models a chain of observed variables as the output of a chain of hidden states. Given such a chain of observations, it can deduce the relationships among the hidden states and between the hidden states and the output variables. It can thus also predict future hidden states and output variables.
Model| Nested Class Summary | |
|---|---|
static class |
HMM.Delta
A HMM.Delta object contains a diff of the sufficient
statistics for an HMM. |
static class |
HMM.Prediction
A Prediction object contains an array of states
and a matching array of weights. |
static class |
HMM.Segment
A Segment object contains the internal model state
associated with a single state. |
| Nested classes inherited from class ostore.oil.SegmentedModel |
|---|
|
| Nested classes inherited from class ostore.oil.Model |
|---|
|
| Field Summary | |
|---|---|
protected Matrix |
emissions
|
static int |
INIT_CODE_CLUSTERING
Initialize HMM with priors which are useful for a
clustering application. |
static int |
INIT_TRANSITIONS_CLUSTER
Use random transition priors, but weight self-transitions heavily. |
static int |
INIT_TRANSITIONS_RANDOM
Use random transition priors. |
protected Array |
marginals
|
protected QSVector |
states
|
protected Matrix |
transitions
|
| Constructor Summary | |
|---|---|
HMM(InputBuffer buffer)
Constructs a HMM from its
serialized form. |
|
HMM(int type,
int num_states,
int num_outputs,
double epsilon)
Create a new HMM.
|
|
| Method Summary | |
|---|---|
void |
add_delta(Model.Delta d)
Incorporate the information from a Delta into this
Model.
|
void |
add_segment(SegmentedModel.Segment s)
Incorporates the portion of the model contained in the specified Segment. |
void |
choose_segments(int num)
Selects the num most relevant Segments,
discarding the rest.
|
void |
clear()
Forget all observations recorded since the last call to
clear or recalculate. |
void |
clear(int num)
Forget the least-recent recorded observations. |
double |
loglikelihood()
Calculates the log-likelihood of all recorded
observations. |
QuickSerializable[] |
outliers()
Returns the recent observations which the model assigns the lowest likelihood. |
Model.Prediction |
predict(int horizon)
Estimates the current and future occurrences of each state. |
Model.Delta |
recalculate()
Updates the internal model parameters using the EM algorithm. |
void |
record(QuickSerializable output)
Notes an observation for later processing. |
void |
record(QuickSerializable[] observations)
Notes a group of observations for later processing. |
void |
serialize(OutputBuffer buffer)
Add the object to the buffer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int INIT_TRANSITIONS_RANDOM
public static final int INIT_TRANSITIONS_CLUSTER
public static final int INIT_CODE_CLUSTERING
HMM with priors which are useful for a
clustering application.
protected QSVector states
protected Array marginals
protected Matrix transitions
protected Matrix emissions
| Constructor Detail |
public HMM(int type,
int num_states,
int num_outputs,
double epsilon)
HMM.
Initialize the states and sufficient statistic priors using the
specified prototype.
type - A code specifying how to initialize the sufficient
statistic priors should be generated. (See
INIT_CODE_* above).num_states - The number of hidden states to assume.num_outputs - The total number of outputs to expect (this
variable is not binding; it just produces
better emission priors).epsilon - The convergence threshold. The inference algorithm
will iterate until the log-likelihood converges to
within epsilon times the sequence length.
public HMM(InputBuffer buffer)
throws QSException
HMM from its
serialized form.
| Method Detail |
public void record(QuickSerializable output)
Modelrecalculate method is called.
record in interface Modeloutput - Any event, value, etc. that this
Model understands.public void record(QuickSerializable[] observations)
ModelModel to process a group of observations in
bulk, potentially saving resources.
record in interface Modelobservations - An array of events, values, etc., not
necessarily all the same type, that this
Model understands.public void clear(int num)
Modelrecorded observations.
clear in interface Modelpublic void clear()
Modelrecorded since the last call to
clear or recalculate.
clear in interface Modelpublic QuickSerializable[] outliers()
Model
outliers in interface Modelpublic void add_segment(SegmentedModel.Segment s)
SegmentedModelSegment.
add_segment in interface SegmentedModels - The Segment to add.SegmentedModel.choose_segments(int)public void add_delta(Model.Delta d)
ModelDelta into this
Model.
The resulting Model should be equivalent to that which
produced the Delta, given that they began in the same
state. Subclasses of Model employ specific subclasses
of Delta.
add_delta in interface Modelpublic double loglikelihood()
Modelrecorded
observations. Only observations recorded since the last call to
clear or recalculate are considered.
loglikelihood in interface ModelD) given the current
model (M); log(p(D|M)). If no
observations exist, it returns Double.NaN.public Model.Delta recalculate()
Delta. They are also added to this
model's sufficient statistics, so they will affect future
calculations.
recalculate in interface ModelDelta containing the expected
transition, emission, and marginal counts for each state. If no
observations have been made, a null delta will be returned.Model.recalculate()public void choose_segments(int num)
num most relevant Segments,
discarding the rest.
This method chooses the top Segments found by
predict(int).
choose_segments in interface SegmentedModelnum - The number of Segments to retain.public Model.Prediction predict(int horizon)
recalculate
to estimate marginal counts for each state, but extends the current
sequence of observations with a series of observations to new
imaginary observation. Thus the states expected to occurr in the
near future (estimated by transition probabilities) are considered
in addition to the states believed to have just occurred.
predict in interface Modelhorizon - The number of observations to look into the future
Prediction containing the estimated state
marginal counts, sorted.Model.predict(int)public void serialize(OutputBuffer buffer)
QuickSerializablebuffer.
serialize in interface QuickSerializablebuffer - the output buffer to add the object to
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||