本文整理汇总了Python中modshogun.RealFeatures.get_feature_vector方法的典型用法代码示例。如果您正苦于以下问题:Python RealFeatures.get_feature_vector方法的具体用法?Python RealFeatures.get_feature_vector怎么用?Python RealFeatures.get_feature_vector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modshogun.RealFeatures
的用法示例。
在下文中一共展示了RealFeatures.get_feature_vector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feature_function
# 需要导入模块: from modshogun import RealFeatures [as 别名]
# 或者: from modshogun.RealFeatures import get_feature_vector [as 别名]
def feature_function():
from modshogun import RealFeatures
from modshogun import CSVFile
import numpy as np
#3x3 random matrix
feat_arr = np.random.rand(3, 3)
#initialize RealFeatures from numpy array
features = RealFeatures(feat_arr)
#get matrix value function
print features.get_feature_matrix(features)
#get selected column of matrix
print features.get_feature_vector(1)
#get number of columns
print features.get_num_features()
#get number of rows
print features.get_num_vectors()
feats_from_csv = RealFeatures(CSVFile("csv/feature.csv"))
print "csv is ", feats_from_csv.get_feature_matrix()
示例2: train
# 需要导入模块: from modshogun import RealFeatures [as 别名]
# 或者: from modshogun.RealFeatures import get_feature_vector [as 别名]
def train(self, images, labels):
"""
Train eigenfaces
"""
print "Train...",
#copy labels
self._labels = labels;
#transform the numpe vector to shogun structure
features = RealFeatures(images)
#PCA
self.pca = PCA()
#set dimension
self.pca.set_target_dim(self._num_components);
#compute PCA
self.pca.init(features)
for sampleIdx in range(features.get_num_vectors()):
v = features.get_feature_vector(sampleIdx);
p = self.pca.apply_to_feature_vector(v);
self._projections.insert(sampleIdx, p);
print "ok!"