pyhctsa.operations.model_fit.hmm_fit¶
-
pyhctsa.operations.model_fit.hmm_fit(y, train_p=
0.8, num_states=3)¶ A hidden Markov model fitted to the first part of the series, and how well it describes the rest.
Fits a hidden Markov model (HMM) with Gaussian emissions to the first
train_pproportion of the time series (hctsa’sMF_hmm_Fit, by Baum-Welch EM withhmmlearn). The emissions of all states share one variance (a tied covariance). The model is trained with at most 30 cycles of EM (Baum-Welch), or until convergence.The fit is deterministic. EM is run from six fixed starting points (state means at the quantiles
(k-1/2)/num_statesof the training data, or evenly spaced within one standard deviation of its mean; a variance equal to that of the training data; and probabilities 0.5, 0.9 and 0.99 of staying in a state); the fit with the highest training log-likelihood (of the training data under the fit’s final parameters) is kept (see_gaussian_hmm_fit()). The shared variance cannot fall below 1% of the variance of the training data, so that states placed on a few repeated values do not give unbounded likelihoods.- Parameters:¶
- Returns:¶
Dictionary of statistics based on the fitted HMM: the sorted state means (
Mu_1, …) and theirmeanMu,rangeMu,maxMu,minMu; the tied covarianceCov; the transition matrix summariesPmeandiag,stdmeanP(standard deviation across states of the mean probability of moving into each state),maxPandstdP; the log-likelihood per sample of the training part under the fitted model,LLtrainpersample; and the test log-likelihood per sampleLLtestpersampleandLLdifference(test minus training).- Return type:¶
dict