本文整理汇总了Python中shogun.Features.StringWordFeatures.get_num_vectors方法的典型用法代码示例。如果您正苦于以下问题:Python StringWordFeatures.get_num_vectors方法的具体用法?Python StringWordFeatures.get_num_vectors怎么用?Python StringWordFeatures.get_num_vectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shogun.Features.StringWordFeatures
的用法示例。
在下文中一共展示了StringWordFeatures.get_num_vectors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: distribution_hmm_modular
# 需要导入模块: from shogun.Features import StringWordFeatures [as 别名]
# 或者: from shogun.Features.StringWordFeatures import get_num_vectors [as 别名]
def distribution_hmm_modular(fm_cube, N, M, pseudo, order, gap, reverse, num_examples):
from shogun.Features import StringWordFeatures, StringCharFeatures, CUBE
from shogun.Distribution import HMM, BW_NORMAL
charfeat=StringCharFeatures(CUBE)
charfeat.set_features(fm_cube)
feats=StringWordFeatures(charfeat.get_alphabet())
feats.obtain_from_char(charfeat, order-1, order, gap, reverse)
hmm=HMM(feats, N, M, pseudo)
hmm.train()
hmm.baum_welch_viterbi_train(BW_NORMAL)
num_examples=feats.get_num_vectors()
num_param=hmm.get_num_model_parameters()
for i in xrange(num_examples):
for j in xrange(num_param):
hmm.get_log_derivative(j, i)
best_path=0
best_path_state=0
for i in xrange(num_examples):
best_path+=hmm.best_path(i)
for j in xrange(N):
best_path_state+=hmm.get_best_path_state(i, j)
lik_example = hmm.get_log_likelihood()
lik_sample = hmm.get_log_likelihood_sample()
return lik_example, lik_sample, hmm
示例2: distribution_linearhmm_modular
# 需要导入模块: from shogun.Features import StringWordFeatures [as 别名]
# 或者: from shogun.Features.StringWordFeatures import get_num_vectors [as 别名]
def distribution_linearhmm_modular (fm_dna=traindna,order=3,gap=0,reverse=False):
from shogun.Features import StringWordFeatures, StringCharFeatures, DNA
from shogun.Distribution import LinearHMM
charfeat=StringCharFeatures(DNA)
charfeat.set_features(fm_dna)
feats=StringWordFeatures(charfeat.get_alphabet())
feats.obtain_from_char(charfeat, order-1, order, gap, reverse)
hmm=LinearHMM(feats)
hmm.train()
hmm.get_transition_probs()
num_examples=feats.get_num_vectors()
num_param=hmm.get_num_model_parameters()
for i in range(num_examples):
for j in range(num_param):
hmm.get_log_derivative(j, i)
out_likelihood = hmm.get_log_likelihood()
out_sample = hmm.get_log_likelihood_sample()
return hmm,out_likelihood ,out_sample
示例3: histogram
# 需要导入模块: from shogun.Features import StringWordFeatures [as 别名]
# 或者: from shogun.Features.StringWordFeatures import get_num_vectors [as 别名]
def histogram ():
print 'Histogram'
from shogun.Features import StringWordFeatures, StringCharFeatures, DNA
from shogun.Distribution import Histogram
order=3
gap=0
reverse=False
charfeat=StringCharFeatures(DNA)
charfeat.set_features(fm_dna)
feats=StringWordFeatures(charfeat.get_alphabet())
feats.obtain_from_char(charfeat, order-1, order, gap, reverse)
histo=Histogram(feats)
histo.train()
histo.get_histogram()
num_examples=feats.get_num_vectors()
num_param=histo.get_num_model_parameters()
#for i in xrange(num_examples):
# for j in xrange(num_param):
# histo.get_log_derivative(j, i)
histo.get_log_likelihood()
histo.get_log_likelihood_sample()
示例4: linear_hmm
# 需要导入模块: from shogun.Features import StringWordFeatures [as 别名]
# 或者: from shogun.Features.StringWordFeatures import get_num_vectors [as 别名]
def linear_hmm ():
print 'LinearHMM'
from shogun.Features import StringWordFeatures, StringCharFeatures, DNA
from shogun.Distribution import LinearHMM
order=3
gap=0
reverse=False
charfeat=StringCharFeatures(DNA)
charfeat.set_features(fm_dna)
feats=StringWordFeatures(charfeat.get_alphabet())
feats.obtain_from_char(charfeat, order-1, order, gap, reverse)
hmm=LinearHMM(feats)
hmm.train()
hmm.get_transition_probs()
num_examples=feats.get_num_vectors()
num_param=hmm.get_num_model_parameters()
for i in xrange(num_examples):
for j in xrange(num_param):
hmm.get_log_derivative(j, i)
hmm.get_log_likelihood()
hmm.get_log_likelihood_sample()