Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getHmmModel(self):
''' get hmm model from training data '''
# GaussianHMM
# model = hmm.GaussianHMM(numStates, "diag") # initialize hmm model
# Gaussian Mixture HMM
model = hmm.GMMHMM(n_components = self.nComp, n_mix = self.nMix, \
transmat_prior = self.transmatPrior, startprob_prior = self.startprobPrior, \
covariance_type = self.covarianceType, n_iter = self.n_iter)
model.fit(self.trainData) # get optimal parameters
self.hmmModel = model
init_new_score_level()
for n_mix in model_config['GMM_state_amount']:
update_last_score_level()
if does_bad_score_count_hit(2) and n_mix>5:
clear_last_score_level()
break
init_new_score_level()
for n_components in model_config['hmm_hidden_state_amount']:
update_last_score_level()
if does_bad_score_count_hit(2) and n_components>5:
clear_last_score_level()
break
model = hmmlearn.hmm.GMMHMM(
n_components=n_components,
n_mix=n_mix,
covariance_type=covariance_type,
params="mct",
init_params="cmt",
n_iter=n_iter)
start_prob = np.zeros(n_components)
start_prob[0] = 1
model.startprob_ = start_prob
now_model_config = {
"hmm_hidden_state_amount": n_components,
"gaussianhmm_covariance_type_string": covariance_type,
"hmm_max_train_iteration": n_iter,
"GMM_state_amount": n_mix,
}
def build_hmm(n_components, n_mix):
'''
Create models with passed parameters.
'''
model = hmm.GMMHMM(n_components=n_components, n_mix=n_mix, random_state=random_state)
return model
self.hmm_0 = build_hmm(n_components, n_mix)