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


Python StringCharFeatures.get_features方法代码示例

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


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

示例1: features_string_file_modular

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import get_features [as 别名]
def features_string_file_modular(directory, fname):
	from shogun.Features import StringCharFeatures, RAWBYTE
	from shogun.IO import AsciiFile

	# load features from directory
	f=StringCharFeatures(RAWBYTE)
	f.load_from_directory(directory)

	#and output several stats
	#print("max string length", f.get_max_vector_length())
	#print("number of strings", f.get_num_vectors())
	#print("length of first string", f.get_vector_length(0))
	#print("str[0,0:3]", f.get_feature(0,0), f.get_feature(0,1), f.get_feature(0,2))
	#print("len(str[0])", f.get_vector_length(0))
	#print("str[0]", f.get_feature_vector(0))

	#or load features from file (one string per line)
	fil=AsciiFile(fname)
	f.load(fil)
	#print(f.get_features())

	#or load fasta file
	#f.load_fasta('fasta.fa')
	#print(f.get_features())
	return f.get_features(), f
开发者ID:coodoing,项目名称:shogun,代码行数:27,代码来源:features_string_file_modular.py

示例2: features_string_char_modular

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import get_features [as 别名]
def features_string_char_modular(strings):
    from shogun.Features import StringCharFeatures, RAWBYTE
    from numpy import array

    # create string features
    f = StringCharFeatures(strings, RAWBYTE)

    # and output several stats
    # print "max string length", f.get_max_vector_length()
    # print "number of strings", f.get_num_vectors()
    # print "length of first string", f.get_vector_length(0)
    # print "string[5]", ''.join(f.get_feature_vector(5))
    # print "strings", f.get_features()

    # replace string 0
    f.set_feature_vector(array(["t", "e", "s", "t"]), 0)

    # print "strings", f.get_features()
    return f.get_features(), f
开发者ID:joseph-chan,项目名称:rqpersonalsvn,代码行数:21,代码来源:features_string_char_modular.py

示例3:

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import get_features [as 别名]
from shogun.Features import StringCharFeatures, StringFileCharFeatures, RAWBYTE
from shogun.Library import UNCOMPRESSED,LZO,GZIP,BZIP2,LZMA, MSG_DEBUG
from shogun.PreProc import DecompressCharString

f=StringFileCharFeatures('features_string_char_compressed_modular.py', RAWBYTE)

print "original strings", f.get_features()

#uncompressed
f.save_compressed("foo_uncompressed.str", UNCOMPRESSED, 1)
f2=StringCharFeatures(RAWBYTE);
f2.load_compressed("foo_uncompressed.str", True)
print "uncompressed strings", f2.get_features()
print

# load compressed data and uncompress on load

#lzo
f.save_compressed("foo_lzo.str", LZO, 9)
f2=StringCharFeatures(RAWBYTE);
f2.load_compressed("foo_lzo.str", True)
print "lzo strings", f2.get_features()
print

##gzip
f.save_compressed("foo_gzip.str", GZIP, 9)
f2=StringCharFeatures(RAWBYTE);
f2.load_compressed("foo_gzip.str", True)
print "gzip strings", f2.get_features()
print
开发者ID:memimo,项目名称:shogun-liblinear,代码行数:32,代码来源:features_string_char_compressed_modular.py

示例4:

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import get_features [as 别名]
from shogun.Features import StringCharFeatures, RAWBYTE
from numpy import array

#create string features
f=StringCharFeatures(['hey','guys','i','am','a','string'], RAWBYTE)

#and output several stats
print "max string length", f.get_max_vector_length()
print "number of strings", f.get_num_vectors()
print "length of first string", f.get_vector_length(0)
print "string[5]", ''.join(f.get_feature_vector(5))
print "strings", f.get_features()

#replace string 0
f.set_feature_vector(array(['t','e','s','t']), 0)

print "strings", f.get_features()
开发者ID:memimo,项目名称:shogun-liblinear,代码行数:19,代码来源:features_string_char_modular.py

示例5: file

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import get_features [as 别名]
from shogun.Features import StringCharFeatures, RAWBYTE

# load features from directory
f=StringCharFeatures(RAWBYTE)
f.load_from_directory(".")

#and output several stats
print "max string length", f.get_max_vector_length()
print "number of strings", f.get_num_vectors()
print "length of first string", f.get_vector_length(0)
print "str[0,0:3]", f.get_feature(0,0), f.get_feature(0,1), f.get_feature(0,2)
print "len(str[0])", f.get_vector_length(0)
print "str[0]", f.get_feature_vector(0)

#or load features from file (one string per line)
f.load('features_string_char_modular.py')
print f.get_features()

#or load fasta file
#f.load_fasta('fasta.fa')
#print f.get_features()
开发者ID:memimo,项目名称:shogun-liblinear,代码行数:23,代码来源:features_string_file_modular.py


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