mlpack.hmm_generate

hmm_generate(...)Hidden Markov Model (HMM) Sequence Generator

>>> from mlpack import hmm_generate

This utility takes an already-trained HMM, specified as the 'model' parameter, and generates a random observation sequence and hidden state sequence based on its parameters. The observation sequence may be saved with the 'output' output parameter, and the internal state sequence may be saved with the 'state' output parameter.

The state to start the sequence in may be specified with the 'start_state' parameter.

For example, to generate a sequence of length 150 from the HMM 'hmm' and save the observation sequence to 'observations' and the hidden state sequence to 'states', the following command may be used:

>>> output = hmm_generate(model=hmm, length=150)

>>> observations = output['output']

>>> states = output['state']

## input options

- length (int): [required] Length of sequence to generate. Default value 0.
- model (mlpack.HMMModelType): [required] Trained HMM to generate sequences with.
- copy_all_inputs (bool): If specified, all input parameters will be deep copied before the method is run. This is useful for debugging problems where the input parameters are being modified by the algorithm, but can slow down the code.
- seed (int): Random seed. If 0, 'std::time(NULL)' is used. Default value 0.
- start_state (int): Starting state of sequence. Default value 0.
- verbose (bool): Display informational messages and the full list of parameters and timers at the end of execution.

## output options

The return value from the binding is a dict containing the following elements:

- output (numpy matrix, float dtype): Matrix to save observation sequence to.
- state (numpy matrix, int dtype): Matrix to save hidden state sequence to.