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


Python CombinedKernel.set_subkernel_weights方法代码示例

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


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

示例1: get_weighted_spectrum_kernel

# 需要导入模块: from shogun.Kernel import CombinedKernel [as 别名]
# 或者: from shogun.Kernel.CombinedKernel import set_subkernel_weights [as 别名]
def get_weighted_spectrum_kernel(subfeats_list, options):
	"""build weighted spectrum kernel with non-redundant k-mer list (removing reverse complement)

	Arguments:
	subfeats_list -- list of sub-feature objects
	options -- object containing option data 

	Return:
	CombinedFeatures of StringWord(Ulong)Features, CombinedKernel of CommWord(Ulong)StringKernel 
	"""
	kmerlen = options.kmerlen
	kmerlen2 = options.kmerlen2

	subkernels = 0
	kernel = CombinedKernel()
	feats = CombinedFeatures()

	for subfeats in subfeats_list:
		feats.append_feature_obj(subfeats)

	for k in xrange(kmerlen, kmerlen2+1):
		if k <= 8:
			subkernel = CommWordStringKernel(10, False)
		else:
			subkernel = CommUlongStringKernel(10, False)

		kernel.append_kernel(subkernel)
		subkernels+=1

	kernel.init(feats, feats)

	kernel.set_subkernel_weights(numpy.array([1/float(subkernels)]*subkernels, numpy.dtype('float64')))

	return kernel
开发者ID:aleasoni,项目名称:Summer-Research-2013,代码行数:36,代码来源:kmersvm_train.py

示例2: StratifiedCrossValidationSplitting

# 需要导入模块: from shogun.Kernel import CombinedKernel [as 别名]
# 或者: from shogun.Kernel.CombinedKernel import set_subkernel_weights [as 别名]
c2.build_values(-4.0, 4.0, R_EXP);
param_tree_root.append_child(c2)

splitting_strategy   = StratifiedCrossValidationSplitting(labels, 50)
evaluation_criterium = ContingencyTableEvaluation(ACCURACY)
cross_validation     = CrossValidation(classifier, feats_train, labels, splitting_strategy, evaluation_criterium)
model_selection      = GridSearchModelSelection(param_tree_root, cross_validation)
best_parameters      = model_selection.select_model(True)

print "Best parameters: ",
best_parameters.print_tree()
best_parameters.apply_to_machine(classifier)

classifier.train()
w=kernel.get_subkernel_weights()
kernel.set_subkernel_weights(w)

# Plot ROC curve
subplot(111)
ROC_evaluation=ROCEvaluation()
ROC_evaluation.evaluate(classifier.apply(feats_train),Labels(trainlab))
roc = ROC_evaluation.get_ROC()
plot(roc[0], roc[1])
fill_between(roc[0],roc[1],0,alpha=0.1)
grid(True)
xlabel('FPR')
ylabel('TPR')
title('Train ROC (Width=%.3f, C1=%.3f, C2=%.3f) ROC curve = %.3f' % (10, classifier.get_C1(), classifier.get_C2(), ROC_evaluation.get_auROC()),size=10)
savefig("data/iri/mkl.png")
"""
subplot(222)
开发者ID:nickponline,项目名称:mkl,代码行数:33,代码来源:irimklms.py


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