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


Python Feature.get_feature_vector方法代码示例

本文整理汇总了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
开发者ID:fangzheng354,项目名称:expert_finding,代码行数:37,代码来源:zmodel.py

示例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
开发者ID:fangzheng354,项目名称:expert_finding,代码行数:12,代码来源:zmodel.py

示例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
开发者ID:fangzheng354,项目名称:expert_finding,代码行数:19,代码来源:zmodel.py


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