Python hmm.GaussianHMM方法代码示例 您所在的位置:网站首页 python调入函数 Python hmm.GaussianHMM方法代码示例

Python hmm.GaussianHMM方法代码示例

2024-05-03 08:26| 来源: 网络整理| 查看: 265

本文整理汇总了Python中hmmlearn.hmm.GaussianHMM方法的典型用法代码示例。如果您正苦于以下问题:Python hmm.GaussianHMM方法的具体用法?Python hmm.GaussianHMM怎么用?Python hmm.GaussianHMM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hmmlearn.hmm的用法示例。

在下文中一共展示了hmm.GaussianHMM方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process # 需要导入模块: from hmmlearn import hmm [as 别名] # 或者: from hmmlearn.hmm import GaussianHMM [as 别名] def process(self): females, males = self.get_file_paths(self.females_training_path, self.males_training_path) # collect voice features female_voice_features = self.collect_features(females) male_voice_features = self.collect_features(males) # generate gaussian mixture models females_gmm = hmm.GaussianHMM(n_components=3) males_gmm = hmm.GaussianHMM(n_components=3) ubm = hmm.GaussianHMM(n_components=3) # fit features to models females_gmm.fit(female_voice_features) males_gmm.fit(male_voice_features) ubm.fit(np.vstack((female_voice_features, male_voice_features))) # save models self.save_gmm(females_gmm, "females") self.save_gmm(males_gmm, "males") self.save_gmm(males_gmm, "ubm") 开发者ID:SuperKogito,项目名称:Voice-based-gender-recognition,代码行数:20,代码来源:ModelsTrainer.py 示例2: test_score_samples_and_decode # 需要导入模块: from hmmlearn import hmm [as 别名] # 或者: from hmmlearn.hmm import GaussianHMM [as 别名] def test_score_samples_and_decode(self): h = hmm.GaussianHMM(self.n_components, self.covariance_type, init_params="st") h.means_ = self.means h.covars_ = self.covars # Make sure the means are far apart so posteriors.argmax() # picks the actual component used to generate the observations. h.means_ = 20 * h.means_ gaussidx = np.repeat(np.arange(self.n_components), 5) n_samples = len(gaussidx) X = self.prng.randn(n_samples, self.n_features) + h.means_[gaussidx] h._init(X) ll, posteriors = h.score_samples(X) assert posteriors.shape == (n_samples, self.n_components) assert np.allclose(posteriors.sum(axis=1), np.ones(n_samples)) viterbi_ll, stateseq = h.decode(X) assert np.allclose(stateseq, gaussidx) 开发者ID:hmmlearn,项目名称:hmmlearn,代码行数:23,代码来源:test_gaussian_hmm.py 示例3: test_fit_zero_variance # 需要导入模块: from hmmlearn import hmm [as 别名] # 或者: from hmmlearn.hmm import GaussianHMM [as 别名] def test_fit_zero_variance(self): # Example from issue #2 on GitHub. X = np.asarray([ [7.15000000e+02, 5.85000000e+02, 0.00000000e+00, 0.00000000e+00], [7.15000000e+02, 5.20000000e+02, 1.04705811e+00, -6.03696289e+01], [7.15000000e+02, 4.55000000e+02, 7.20886230e-01, -5.27055664e+01], [7.15000000e+02, 3.90000000e+02, -4.57946777e-01, -7.80605469e+01], [7.15000000e+02, 3.25000000e+02, -6.43127441e+00, -5.59954834e+01], [7.15000000e+02, 2.60000000e+02, -2.90063477e+00, -7.80220947e+01], [7.15000000e+02, 1.95000000e+02, 8.45532227e+00, -7.03294373e+01], [7.15000000e+02, 1.30000000e+02, 4.09387207e+00, -5.83621216e+01], [7.15000000e+02, 6.50000000e+01, -1.21667480e+00, -4.48131409e+01] ]) h = hmm.GaussianHMM(3, self.covariance_type) h.fit(X) 开发者ID:hmmlearn,项目名称:hmmlearn,代码行数:18,代码来源:test_gaussian_hmm.py 示例4: GMM_HMM # 需要导入模块: from hmmlearn import hmm [as 别名] # 或者: from hmmlearn.hmm import GaussianHMM [as 别名] def GMM_HMM(O, lengths, n_states, verbose=False): # the first step initial a GMM_HMM model # input: # O, array, (n_samples, n_features), observation # lengths, list, lengths of sequence # n_states, number of states # output: # S, the best state sequence # A, the transition probability matrix of the HMM model # model = hmm.GMMHMM(n_components=n_states, n_mix=4, covariance_type="diag", n_iter=1000, verbose=verbose).fit(O, lengths) model = hmm.GaussianHMM(n_components=n_states, covariance_type='diag', n_iter=1000, verbose=verbose).fit(O, lengths) pi = model.startprob_ A = model.transmat_ _, S = model.decode(O, algorithm='viterbi') gamma = model.predict_proba(O) pickle.dump(model, open('C:/Users/Administrator/Desktop/HMM_program/save/GMM_HMM_model.pkl', 'wb')) return S, A, gamma 开发者ID:JINGEWU,项目名称:Stock-Market-Trend-Analysis-Using-HMM-LSTM,代码行数:22,代码来源:GMM_HMM.py 示例5: __init__ # 需要导入模块: from hmmlearn import hmm [as 别名] # 或者: from hmmlearn.hmm import GaussianHMM [as 别名] def __init__(self, model_name='GaussianHMM', n_components=4, cov_type='diag', n_iter=1000): self.model_name = model_name self.n_components = n_components self.cov_type = cov_type self.n_iter = n_iter self.models = [] if self.model_name == 'GaussianHMM': self.model = hmm.GaussianHMM(n_components=self.n_components, covariance_type=self.cov_type, n_iter=self.n_iter) else: raise TypeError('Invalid model type') # X is a 2D numpy array where each row is 13D 开发者ID:PacktPublishing,项目名称:Python-Machine-Learning-Cookbook-Second-Edition,代码行数:16,代码来源:speech_recognizer.py 示例6: process # 需要导入模块: from hmmlearn import hmm [as 别名] # 或者: from hmmlearn.hmm import GaussianHMM [as 别名] def process(self): files = self.get_file_paths(self.females_training_path, self.males_training_path) # read the test directory and get the list of test audio files for file in files: self.total_sample += 1 print("%10s %8s %1s" % ("--> TESTING", ":", os.path.basename(file))) #self.ffmpeg_silence_eliminator(file, file.split('.')[0] + "_without_silence.wav") # extract MFCC & delta MFCC features from audio try: # vector = self.features_extractor.extract_features(file.split('.')[0] + "_without_silence.wav") vector = self.features_extractor.extract_features(file) spk_gmm = hmm.GaussianHMM(n_components=16) spk_gmm.fit(vector) self.spk_vec = spk_gmm.means_ print(self.spk_vec.shape) prediction = list(self.model.predict_classes(self.spk_vec)) print(prediction) if prediction.count(0)


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有