GMMHMM
Hidden Markov Model with Gaussian mixture emissions.
Quickstart
from sktime.detection.hmm_learn.gmm import GMMHMM
estimator = GMMHMM(n_components: int=1, n_mix: int=1, min_covar: float=0.001, startprob_prior: float=1.0, transmat_prior: float=1.0, weights_prior: float=1.0, means_prior: float=0.0, means_weight: float=0.0, covars_prior=None, covars_weight=None, algorithm: str='viterbi', covariance_type: str='diag', random_state=None, n_iter: int=10, tol: float=0.01, verbose: bool=False, params: str='stmcw', init_params: str='stmcw', implementation: str='log')Parameters(16)
- n_componentsint
- Number of states in the model.
- n_mixint
- Number of states in the GMM.
- covariance_type{“spherical”, “diag”, “full”, “tied”}, optional
The type of covariance parameters to use:
- “spherical” — each state uses a single variance value that
applies to all features.
- “spherical” — each state uses a single variance value that
- min_covarfloat, optional
- Floor on the diagonal of the covariance matrix to prevent overfitting. Defaults to 1e-3.
- startprob_priorarray, shape (n_components,), optional
Parameters of the Dirichlet prior distribution for
startprob_.- transmat_priorarray, shape (n_components, n_components), optional
Parameters of the Dirichlet prior distribution for each row of the transition probabilities
transmat_.- weights_priorarray, shape (n_mix,), optional
Parameters of the Dirichlet prior distribution for
weights_.- means_prior, means_weightarray, shape (n_mix,), optional
Mean and precision of the Normal prior distribution for
means_.- covars_prior, covars_weightarray, shape (n_mix,), optional
Parameters of the prior distribution for the covariance matrix
covars_. Ifcovariance_typeis “spherical” or “diag” the prior is the inverse gamma distribution, otherwise — the inverse Wishart distribution.- algorithm{“viterbi”, “map”}, optional
- Decoder algorithm.
- random_state: RandomState or an int seed, optional
- A random number generator instance.
- n_iterint, optional
- Maximum number of iterations to perform.
- tolfloat, optional
- Convergence threshold. EM will stop if the gain in log-likelihood is below this value.
- verbosebool, optional
Whether per-iteration convergence reports are printed to
sys.stderr. Convergence can also be diagnosed using themonitor_attribute.- params, init_paramsstring, optional
The parameters that get updated during (
params) or initialized before (init_params) the training. Can contain any combination of ‘s’ for startprob, ‘t’ for transmat, ‘m’ for means, ‘c’ for covars, and ‘w’ for GMM mixing weights. Defaults to all parameters.- implementation: string, optional
- Determines if the forward-backward algorithm is implemented with logarithms (“log”), or using scaling (“scaling”). The default is to use logarithms for backwards compatibility.
Examples
>>> from sktime.detection.hmm_learn import GMMHMM
>>> from sktime.detection.datagen import piecewise_normal
>>> data = piecewise_normal (
... means = [2, 4, 1 ], lengths = [10, 35, 40 ], random_state = 7
... ). reshape ((- 1, 1))
>>> model = GMMHMM (n_components = 3)
>>> model = model. fit (data)
>>> labeled_data = model. predict (data)