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


Python RealFeatures.apply_preprocessor方法代码示例

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


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

示例1: preprocessor_randomfouriergausspreproc_modular

# 需要导入模块: from modshogun import RealFeatures [as 别名]
# 或者: from modshogun.RealFeatures import apply_preprocessor [as 别名]
def preprocessor_randomfouriergausspreproc_modular (fm_train_real=traindat,fm_test_real=testdat,width=1.4,size_cache=10):
	from modshogun import Chi2Kernel
	from modshogun import RealFeatures
	from modshogun import RandomFourierGaussPreproc

	feats_train=RealFeatures(fm_train_real)
	feats_test=RealFeatures(fm_test_real)

	preproc=RandomFourierGaussPreproc()
	preproc.init(feats_train)
	feats_train.add_preprocessor(preproc)
	feats_train.apply_preprocessor()
	feats_test.add_preprocessor(preproc)
	feats_test.apply_preprocessor()

	kernel=Chi2Kernel(feats_train, feats_train, width, size_cache)

	km_train=kernel.get_kernel_matrix()
	kernel.init(feats_train, feats_test)
	km_test=kernel.get_kernel_matrix()

	return km_train,km_test,kernel
开发者ID:42MachineLearning,项目名称:shogun,代码行数:24,代码来源:preprocessor_randomfouriergausspreproc_modular.py

示例2: preprocessor_prunevarsubmean_modular

# 需要导入模块: from modshogun import RealFeatures [as 别名]
# 或者: from modshogun.RealFeatures import apply_preprocessor [as 别名]
def preprocessor_prunevarsubmean_modular (fm_train_real=traindat,fm_test_real=testdat,width=1.4,size_cache=10):
	from modshogun import Chi2Kernel
	from modshogun import RealFeatures
	from modshogun import PruneVarSubMean

	feats_train=RealFeatures(fm_train_real)
	feats_test=RealFeatures(fm_test_real)

	preproc=PruneVarSubMean()
	preproc.init(feats_train)
	feats_train.add_preprocessor(preproc)
	feats_train.apply_preprocessor()
	feats_test.add_preprocessor(preproc)
	feats_test.apply_preprocessor()

	kernel=Chi2Kernel(feats_train, feats_train, width, size_cache)

	km_train=kernel.get_kernel_matrix()
	kernel.init(feats_train, feats_test)
	km_test=kernel.get_kernel_matrix()

	return km_train,km_test,kernel
开发者ID:42MachineLearning,项目名称:shogun,代码行数:24,代码来源:preprocessor_prunevarsubmean_modular.py

示例3: preprocessor_normone_modular

# 需要导入模块: from modshogun import RealFeatures [as 别名]
# 或者: from modshogun.RealFeatures import apply_preprocessor [as 别名]
def preprocessor_normone_modular (fm_train_real=traindat,fm_test_real=testdat,width=1.4,size_cache=10):

	from modshogun import Chi2Kernel
	from modshogun import RealFeatures
	from modshogun import NormOne

	feats_train=RealFeatures(fm_train_real)
	feats_test=RealFeatures(fm_test_real)

	preprocessor=NormOne()
	preprocessor.init(feats_train)
	feats_train.add_preprocessor(preprocessor)
	feats_train.apply_preprocessor()
	feats_test.add_preprocessor(preprocessor)
	feats_test.apply_preprocessor()

	kernel=Chi2Kernel(feats_train, feats_train, width, size_cache)

	km_train=kernel.get_kernel_matrix()
	kernel.init(feats_train, feats_test)
	km_test=kernel.get_kernel_matrix()

	return km_train,km_test,kernel
开发者ID:42MachineLearning,项目名称:shogun,代码行数:25,代码来源:preprocessor_normone_modular.py

示例4: RealFeatures

# 需要导入模块: from modshogun import RealFeatures [as 别名]
# 或者: from modshogun.RealFeatures import apply_preprocessor [as 别名]
from modshogun import CSVFile, RealFeatures, RescaleFeatures
from scipy.linalg import solve_triangular, cholesky, sqrtm, inv
import matplotlib.pyplot as pyplot
import numpy

# load wine features
features = RealFeatures(CSVFile('../data/fm_wine.dat'))

print('%d vectors with %d features.' % (features.get_num_vectors(), features.get_num_features()))
print('original features mean = ' + str(numpy.mean(features, axis=1)))

# rescale the features to [0,1]
feature_rescaling = RescaleFeatures()
feature_rescaling.init(features)
features.add_preprocessor(feature_rescaling)
features.apply_preprocessor()

print('mean after rescaling = ' + str(numpy.mean(features, axis=1)))

# remove mean from data
data = features.get_feature_matrix()
data = data.T
data-= numpy.mean(data, axis=0)
print numpy.mean(data, axis=0)

fig, axarr = pyplot.subplots(1,2)
axarr[0].matshow(numpy.cov(data.T))

#### whiten data

''' this method to whiten the data didn't really work out
开发者ID:iglesias,项目名称:tests,代码行数:33,代码来源:data_whitening.py


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