当前位置: 首页>>代码示例>>Python>>正文


Python GaussianHMM.means_方法代码示例

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


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

示例1: bench_gaussian_hmm

# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import means_ [as 别名]
def bench_gaussian_hmm(size):
    title = "benchmarking Gaussian HMM on a sample of size {0}".format(size)
    print(title.center(36, " "))
    ghmm = GaussianHMM()
    ghmm.means_ = [[42], [24]]
    ghmm.covars_ = [[1], [1]]

    with timed_step("generating sample"):
        sample, _states = ghmm.sample(size)

    with timed_step("fitting"):
        fit = GaussianHMM(n_components=2).fit([sample])

    with timed_step("estimating states"):
        fit.predict(sample)
开发者ID:LoganDing,项目名称:hmmlearn,代码行数:17,代码来源:speed.py

示例2: calculate_hmm_g

# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import means_ [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)
开发者ID:anukat2015,项目名称:Twitter_DA_Recognition,代码行数:21,代码来源:hmm_gaussian.py

示例3: of

# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import means_ [as 别名]
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))
model_gaussian.covars_ = covariance

# model.sample returns both observations as well as hidden states
# the first return argument being the observation and the second
# being the hidden states
Z, X = model_gaussian.sample(100)

# Plotting the observations
plt.plot(Z[:, 0], Z[:, 1], "-o", label="observations",
开发者ID:xenron,项目名称:sandbox-da-python,代码行数:33,代码来源:B04016_07_06.py

示例4: main

# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import means_ [as 别名]

#.........这里部分代码省略.........
                group.flag_multiple_hmms = False
                group.hmm = group.hmm[0]
            elif(len(group.hmm) == len(histone_file_name_list)): flag_multiple_hmms = True
            else: error_handler.throw_error("FP_NB_HMMS")

    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)

开发者ID:Marvin84,项目名称:reg-gen,代码行数:68,代码来源:Main.py

示例5: mean

# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import means_ [as 别名]
		stateCovs[i] = covAll * args.fractionBG/args.ploidy; # since if the variance is 0, the probability of observing anything but the mean (0) is 0
	else:
		stateCovs[i] = covAll * float(i)/args.ploidy;
	cnvsToStateIs[i]=i
	statePDFMaxima[i]=np.log(multivariate_normal.pdf(x=stateMeans[i],mean=stateMeans[i],cov=stateCovs[i]))

cnvsToStateIs0=cnvsToStateIs;
stateIsToCNVs0 = stateIsToCNVs;
if len(IDs)==1:
	stateCovs = np.expand_dims(stateCovs,1)


#model = GaussianHMM(len(states),covariance_type="full",n_iter=1);
model = GaussianHMM(numStates,covariance_type="full", n_iter=1);
###insert my own params
model.means_ = stateMeans;
model.covars_ = stateCovs;

### make transmat
if args.transition <= -100:
	transitionMatrix = (1-np.eye(numStates))*args.transition*np.log(10);
	model._log_transmat =transitionMatrix;
else:
	transitionMatrix = np.add(np.eye(numStates)*(1-(numStates-1)*10**args.transition),(1-np.eye(numStates))*10**args.transition);
	model._set_transmat(transitionMatrix);

if args.verbose>0: sys.stderr.write(np.array_str(model._log_transmat)+"\n");

#exit;
meanNormal = meanAll;
normalState = cnvsToStateIs[args.ploidy];
开发者ID:Carldeboer,项目名称:BigWig-Tools,代码行数:33,代码来源:findCopyNumber.py


注:本文中的hmmlearn.hmm.GaussianHMM.means_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。