本文整理汇总了Python中hmmlearn.hmm.GaussianHMM.startprob_方法的典型用法代码示例。如果您正苦于以下问题:Python GaussianHMM.startprob_方法的具体用法?Python GaussianHMM.startprob_怎么用?Python GaussianHMM.startprob_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hmmlearn.hmm.GaussianHMM
的用法示例。
在下文中一共展示了GaussianHMM.startprob_方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calculate_hmm_g
# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import startprob_ [as 别名]
def calculate_hmm_g(training_set, test_set, taxonomy, cursor, connection, settings):
da_id_taxonomy = find_da_id(taxonomy, cursor)
states, start_probability, transition_probability = start_transition_probability_extraction(training_set, taxonomy)
n_states = len(states)
feature_list = extract_features_training_set_gaus(training_set, taxonomy, settings)
n_features = len(feature_list[states[0]][0])
mean = calculate_means(states, feature_list, n_features)
covariance = calculate_covariance(states, feature_list, n_features)
# covariance = diag_cov(states, feature_list, n_features, mean)
model = GaussianHMM(n_components=n_states, covariance_type='full')
model.startprob_ = start_probability
model.transmat_ = transition_probability
model.means_ = mean
model.covars_ = covariance
test_seq, con_pathes = extract_features_test_set_gaus(test_set, taxonomy, settings)
da_predictions(test_seq, model, con_pathes, states, da_id_taxonomy, taxonomy, cursor, connection)
示例2: main
# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import startprob_ [as 别名]
#.........这里部分代码省略.........
else: # Argument was not passed
for group in group_list:
group.flag_multiple_hmms = False
if(group.dnase_only):
if(bias_correction): group.hmm = hmm_data.get_default_hmm_dnase_bc()
else: group.hmm = hmm_data.get_default_hmm_dnase()
elif(group.histone_only):
group.hmm = hmm_data.get_default_hmm_histone()
else:
if(bias_correction): group.hmm = hmm_data.get_default_hmm_dnase_histone_bc()
else: group.hmm = hmm_data.get_default_hmm_dnase_histone()
# Creating scikit HMM list
for group in group_list:
if(group.flag_multiple_hmms):
hmm_list = []
for hmm_file_name in group.hmm:
try:
hmm_scaffold = HMM()
hmm_scaffold.load_hmm(hmm_file_name)
if(int(hmm_ver.split(".")[0]) <= 0 and int(hmm_ver.split(".")[1]) <= 1):
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full",
transmat=array(hmm_scaffold.A), startprob=array(hmm_scaffold.pi))
scikit_hmm.means_ = array(hmm_scaffold.means)
scikit_hmm.covars_ = array(hmm_scaffold.covs)
else:
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full")
scikit_hmm.startprob_ = array(hmm_scaffold.pi)
scikit_hmm.transmat_ = array(hmm_scaffold.A)
scikit_hmm.means_ = array(hmm_scaffold.means)
scikit_hmm.covars_ = array(hmm_scaffold.covs)
except Exception: error_handler.throw_error("FP_HMM_FILES")
hmm_list.append(scikit_hmm)
group.hmm = hmm_list
else:
scikit_hmm = None
try:
hmm_scaffold = HMM()
hmm_scaffold.load_hmm(group.hmm)
if(int(hmm_ver.split(".")[0]) <= 0 and int(hmm_ver.split(".")[1]) <= 1):
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full",
transmat=array(hmm_scaffold.A), startprob=array(hmm_scaffold.pi))
scikit_hmm.means_ = array(hmm_scaffold.means)
scikit_hmm.covars_ = array(hmm_scaffold.covs)
else:
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full")
scikit_hmm.startprob_ = array(hmm_scaffold.pi)
scikit_hmm.transmat_ = array(hmm_scaffold.A)
scikit_hmm.means_ = array(hmm_scaffold.means)
scikit_hmm.covars_ = array(hmm_scaffold.covs)
except Exception: error_handler.throw_error("FP_HMM_FILES")
group.hmm = scikit_hmm
###################################################################################################
示例3: GaussianHMM
# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import startprob_ [as 别名]
# variables.
model_gaussian = GaussianHMM(n_components=3, covariance_type='full')
# Transition probability as specified above
transition_matrix = np.array([[0.2, 0.6, 0.2],
[0.4, 0.3, 0.3],
[0.05, 0.05, 0.9]])
# Setting the transition probability
model_gaussian.transmat_ = transition_matrix
# Initial state probability
initial_state_prob = np.array([0.1, 0.4, 0.5])
# Setting initial state probability
model_gaussian.startprob_ = initial_state_prob
# As we want to have a 2-D gaussian distribution the mean has to
# be in the shape of (n_components, 2)
mean = np.array([[0.0, 0.0],
[0.0, 10.0],
[10.0, 0.0]])
# Setting the mean
model_gaussian.means_ = mean
# As emission probability is a 2-D gaussian distribution, thus
# covariance matrix for each state would be a 2-D matrix, thus
# overall the covariance matrix for all the states would be in the
# form of (n_components, 2, 2)
covariance = 0.5 * np.tile(np.identity(2), (3, 1, 1))
示例4: scale
# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import startprob_ [as 别名]
for analysis in b.analysis.lowlevel.mfcc:
if analysis is not None:
try:
obs = numpy.array(analysis)
obs = obs.T
obs = obs[1:]
obs = obs.T
obs = scale(obs)
model = GaussianHMM(algorithm='viterbi', covariance_type='diag', covars_prior=0.01,
covars_weight=1, init_params='mc', means_prior=0, means_weight=0,
min_covar=0.001, n_components=3, n_iter=1000, params='mc',
random_state=None, startprob_prior=1.0, tol=0.01, transmat_prior=1.0,
verbose=False)
model.startprob_ = numpy.array([1., 0, 0])
model.startprob_prior = model.startprob_
model.transmat_ = numpy.array([[0.9, 0.1, 0], [0, 0.9, 0.1], [0, 0, 1]])
model.transmat_prior = model.transmat_
model.fit(obs)
pi = model.startprob_
A = model.transmat_
w = numpy.ones((n, m), dtype=numpy.double)
hmm_means = numpy.ones((n, m, d), dtype=numpy.double)
hmm_means[0][0] = model.means_[0]
hmm_means[1][0] = model.means_[1]
hmm_means[2][0] = model.means_[2]
hmm_covars = numpy.array([[ numpy.matrix(numpy.eye(d,d)) for j in xrange(m)] for i in xrange(n)])
hmm_covars[0][0] = model.covars_[0]