本文整理汇总了Python中feature.Feature.get_feature_vector方法的典型用法代码示例。如果您正苦于以下问题:Python Feature.get_feature_vector方法的具体用法?Python Feature.get_feature_vector怎么用?Python Feature.get_feature_vector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feature.Feature
的用法示例。
在下文中一共展示了Feature.get_feature_vector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_train_data
# 需要导入模块: from feature import Feature [as 别名]
# 或者: from feature.Feature import get_feature_vector [as 别名]
def init_train_data(fnames, topics):
print ('[ init_train_data ] =================')
# amap
# key : aid
# value : attr[0] preferance, attr[1] aid , attr[2] aname
train_rank = []
for QID in range(len(topics)):
fname = fnames[QID]
topic = topics[QID]
amap = filter_data(fname)
fea = Feature(topic)
ext_aids = ZC.get_raw_rank(topic, EXT_TRAIN_A_SIZE)
print '[ init_train_data ] amap_1 size = %d ' %(len(amap))
for tid in ext_aids :
if not (tid in amap) :
amap[tid] = (0, tid, '')
print '[ init_train_data ] amap_2 size = %d ' %(len(amap))
for tid in amap :
fv = fea.get_feature_vector(tid)
#print ('[ init_train_data ] %d get feature vector ok.' %(tid))
train_rank.append( (int(amap[tid][0]), reform_vector(fv), QID) )
print '[ init_train_data ] topic : %s ok , train_rank_size = %d' %(topic, len(train_rank))
ZC.dump_cache()
with open('train_rank.dat' , 'w') as f :
pprint.pprint(train_rank, f)
return train_rank
示例2: init_rerank_data
# 需要导入模块: from feature import Feature [as 别名]
# 或者: from feature.Feature import get_feature_vector [as 别名]
def init_rerank_data(aids , topic):
QID = 1
fea = Feature(topic)
rerank_data = []
for tid in aids :
fv = fea.get_feature_vector(tid)
print ('[ init_rerank_data ] %d get feature vector ok.' %(tid))
rerank_data.append( (tid, reform_vector(fv), QID) )
return rerank_data
示例3: init_test_data
# 需要导入模块: from feature import Feature [as 别名]
# 或者: from feature.Feature import get_feature_vector [as 别名]
def init_test_data(fname, topic):
print ('[ init_train_data ] =================')
QID = 1
# amap , key : aid
# value : attr[0] preferance, attr[1] aid , attr[2] aname
amap = filter_data(fname)
fea = Feature(topic)
train_rank = []
for tid in amap :
aid = int(tid)
fv = fea.get_feature_vector(aid)
print ('[ init_train_data ] %d get feature vector ok.' %(aid))
train_rank.append( (aid, reform_vector(fv), QID) )
#ZC.dump_cache()
return train_rank