本文整理汇总了Python中shogun.Features.CombinedFeatures.get_num_vectors方法的典型用法代码示例。如果您正苦于以下问题:Python CombinedFeatures.get_num_vectors方法的具体用法?Python CombinedFeatures.get_num_vectors怎么用?Python CombinedFeatures.get_num_vectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shogun.Features.CombinedFeatures
的用法示例。
在下文中一共展示了CombinedFeatures.get_num_vectors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mkl_binclass_modular
# 需要导入模块: from shogun.Features import CombinedFeatures [as 别名]
# 或者: from shogun.Features.CombinedFeatures import get_num_vectors [as 别名]
def mkl_binclass_modular(fm_train_real=traindat,
fm_test_real=testdat,
fm_label_twoclass=label_traindat):
sc1 = StringCharFeatures(strings1, RAWBYTE)
sc2 = StringCharFeatures(strings2, RAWBYTE)
sfeats1 = StringWordFeatures(RAWBYTE)
sfeats1.obtain_from_char(sc1, 0, 2, 0, False)
skernel1 = CommWordStringKernel(10, False)
skernel1.init(sfeats1, sfeats1)
sfeats2 = StringWordFeatures(RAWBYTE)
sfeats2.obtain_from_char(sc2, 0, 2, 0, False)
skernel2 = CommWordStringKernel(10, False)
skernel2.init(sfeats2, sfeats2)
ffeats = RealFeatures(traindat)
fkernel = LinearKernel(ffeats, ffeats)
fffeats = RealFeatures(traindat)
ffkernel = GaussianKernel(fffeats, fffeats, 1.0)
# COMBINING LINADD FEATURES/KERNELS LEAD TO FAIL
feats_train = CombinedFeatures()
feats_train.append_feature_obj(ffeats)
#feats_train.append_feature_obj(fffeats)
feats_train.append_feature_obj(sfeats2)
print feats_train.get_num_vectors()
kernel = CombinedKernel()
kernel.append_kernel(fkernel)
#kernel.append_kernel(ffkernel)
kernel.append_kernel(skernel2)
kernel.init(feats_train, feats_train)
labels = RegressionLabels(fm_label_twoclass)
mkl = MKLRegression()
mkl.set_mkl_norm(1) #2,3
mkl.set_C(1, 1)
mkl.set_kernel(kernel)
mkl.set_labels(labels)
mkl.io.enable_file_and_line()
mkl.io.set_loglevel(MSG_DEBUG)