本文整理汇总了Python中shogun.Features.StringCharFeatures.set_string_features方法的典型用法代码示例。如果您正苦于以下问题:Python StringCharFeatures.set_string_features方法的具体用法?Python StringCharFeatures.set_string_features怎么用?Python StringCharFeatures.set_string_features使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shogun.Features.StringCharFeatures
的用法示例。
在下文中一共展示了StringCharFeatures.set_string_features方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_predictions
# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import set_string_features [as 别名]
def get_predictions(self, sequence, positions):
seqlen=self.window_right+self.window_left+2
num=len(positions)
testdat = []
for j in xrange(num):
i=positions[j] - self.offset ;
s=sequence[i-self.window_left:i+self.window_right+2]
testdat.append(s)
t=StringCharFeatures(DNA)
t.set_string_features(testdat)
self.wd_kernel.init(self.traindat, t)
l=self.svm.classify().get_labels()
sys.stderr.write("\n...done...\n")
return l
示例2: get_predictions_from_seqdict
# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import set_string_features [as 别名]
def get_predictions_from_seqdict(self, seqdic, site):
""" we need to generate a huge test features object
containing all locations found in each seqdict-sequence
and each location (this is necessary to efficiently
(==fast,low memory) compute the splice outputs
"""
seqlen=self.window_right+self.window_left+2
num=0
for s in seqdic:
num+= len(s.preds[site].positions)
testdat = []
for s in seqdic:
sequence=s.seq
positions=s.preds[site].positions
for j in xrange(len(positions)):
i=positions[j] - self.offset
s=sequence[i-self.window_left:i+self.window_right+2]
testdat.append(s)
t=StringCharFeatures(DNA)
t.set_string_features(testdat)
self.wd_kernel.init(self.traindat, t)
l=self.svm.classify().get_labels()
sys.stderr.write("\n...done...\n")
k=0
for s in seqdic:
num=len(s.preds[site].positions)
scores= num * [0]
for j in xrange(num):
scores[j]=l[k]
k+=1
s.preds[site].set_scores(scores)