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


Python LoadMatrix.load_dna方法代码示例

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


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

示例1: xrange

# 需要导入模块: from tools.load import LoadMatrix [as 别名]
# 或者: from tools.load.LoadMatrix import load_dna [as 别名]
	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()

###########################################################################
# call functions
###########################################################################

if __name__=='__main__':
	from tools.load import LoadMatrix
	lm=LoadMatrix()
	fm_dna=lm.load_dna('../data/fm_train_dna.dat')
	histogram()
开发者ID:memimo,项目名称:shogun-liblinear,代码行数:32,代码来源:distribution_histogram_modular.py

示例2: matches

# 需要导入模块: from tools.load import LoadMatrix [as 别名]
# 或者: from tools.load.LoadMatrix import load_dna [as 别名]
# This is an example for the initialization of the CommWordString-kernel (aka
# Spectrum or n-gram kernel; its name is derived from the unix command comm). This kernel 
# sums over k-mere matches (k='order'). For efficient computing a preprocessor is used 
# that extracts and sorts all k-mers. If 'use_sign' is set to one each k-mere is counted 
# only once. 

from tools.load import LoadMatrix
from sg import sg
lm=LoadMatrix()

traindna=lm.load_dna('../data/fm_train_dna.dat')
testdna=lm.load_dna('../data/fm_test_dna.dat')
parameter_list=[[traindna,testdna,10,3,0,'n',False,'FULL'],
		[traindna,testdna,11,4,0,'n',False,'FULL']]

def kernel_commwordstring (fm_train_dna=traindna,fm_test_dna=testdna,
			    size_cache=10,
			    order=3,gap=0,reverse='n',
			    use_sign=False,normalization='FULL'):

	sg('add_preproc', 'SORTWORDSTRING')
	sg('set_features', 'TRAIN', fm_train_dna, 'DNA')
	sg('convert', 'TRAIN', 'STRING', 'CHAR', 'STRING', 'WORD', order, order-1, gap, reverse)
	sg('attach_preproc', 'TRAIN')

	sg('set_features', 'TEST', fm_test_dna, 'DNA')
	sg('convert', 'TEST', 'STRING', 'CHAR', 'STRING', 'WORD', order, order-1, gap, reverse)
	sg('attach_preproc', 'TEST')

	sg('set_kernel', 'COMMSTRING', 'WORD', size_cache, use_sign, normalization)
	km=sg('get_kernel_matrix', 'TRAIN')
开发者ID:Anshul-Bansal,项目名称:gsoc,代码行数:33,代码来源:kernel_commwordstring.py

示例3: LoadMatrix

# 需要导入模块: from tools.load import LoadMatrix [as 别名]
# 或者: from tools.load.LoadMatrix import load_dna [as 别名]
#!/usr/bin/env python
from tools.load import LoadMatrix

lm = LoadMatrix()

train_dna = lm.load_dna("../data/fm_train_dna.dat")
test_dna = lm.load_dna("../data/fm_test_dna.dat")
label = lm.load_labels("../data/label_train_dna.dat")

parameter_list = [[train_dna, test_dna, label, 20, 0.9, 1e-3, 1], [train_dna, test_dna, label, 20, 2.3, 1e-5, 4]]


def classifier_svmlight_batch_linadd_modular(
    fm_train_dna, fm_test_dna, label_train_dna, degree, C, epsilon, num_threads
):

    from modshogun import StringCharFeatures, BinaryLabels, DNA
    from modshogun import WeightedDegreeStringKernel, MSG_DEBUG

    try:
        from modshogun import SVMLight
    except ImportError:
        print("No support for SVMLight available.")
        return

    feats_train = StringCharFeatures(DNA)
    # feats_train.io.set_loglevel(MSG_DEBUG)
    feats_train.set_features(fm_train_dna)
    feats_test = StringCharFeatures(DNA)
    feats_test.set_features(fm_test_dna)
    degree = 20
开发者ID:JingheZ,项目名称:shogun,代码行数:33,代码来源:classifier_svmlight_batch_linadd_modular.py


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