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


Python TwitterUser.bulk_update方法代码示例

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


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

示例1: range

# 需要导入模块: from smarttypes.model.twitter_user import TwitterUser [as 别名]
# 或者: from smarttypes.model.twitter_user.TwitterUser import bulk_update [as 别名]
TwitterGroup.bulk_delete('all')
for i in range(num_features):
    membership_scores = []
    for j in range(num_items):
        user_id = index_to_twitter_id_dict[j]
        follower_score = users_data[i][j]
        following_score = items_data[i][j]
        membership_score = following_score * following_score
        if membership_score > .001:
            membership_scores.append((membership_score, user_id))
            if user_id not in user_group_map:
                user_group_map[user_id] = [(membership_score, i)]
            else:
                user_group_map[user_id].append((membership_score, i))
    TwitterGroup.upsert_group(i, membership_scores, group_adjacency[i])
print "Done creating groups."

TwitterUser.bulk_update('all', {'scores_groups':None})
i = 0    
for user_id, scores_groups in user_group_map.items():
    twitter_user = TwitterUser.get_by_id(user_id)
    twitter_user.scores_groups = scores_groups
    twitter_user.save()
    if i % 1000 == 0: print "Done with %s users." % i
    i += 1
    
    
    
    
    
开发者ID:greeness,项目名称:SmartTypes,代码行数:27,代码来源:graphlab_to_smarttypes.py

示例2: range

# 需要导入模块: from smarttypes.model.twitter_user import TwitterUser [as 别名]
# 或者: from smarttypes.model.twitter_user.TwitterUser import bulk_update [as 别名]
    group_adjacency.append(membership_scores)

index_to_twitter_id_dict = pickle.load(open("index_to_twitter_id.pickle", "r"))
user_group_map = {}
TwitterGroup.bulk_delete("all")
for i in range(num_features):
    membership_scores = []
    for j in range(num_items):
        user_id = index_to_twitter_id_dict[j]
        follower_score = users_data[i][j]
        following_score = items_data[i][j]
        membership_score = following_score * following_score
        if membership_score > 0.001:
            membership_scores.append((membership_score, user_id))
            if user_id not in user_group_map:
                user_group_map[user_id] = [(membership_score, i)]
            else:
                user_group_map[user_id].append((membership_score, i))
    TwitterGroup.upsert_group(i, membership_scores, group_adjacency[i])
print "Done creating groups."

TwitterUser.bulk_update("all", {"scores_groups": None})
i = 0
for user_id, scores_groups in user_group_map.items():
    twitter_user = TwitterUser.get_by_id(user_id)
    twitter_user.scores_groups = scores_groups
    twitter_user.save()
    if i % 1000 == 0:
        print "Done with %s users." % i
    i += 1
开发者ID:galabad,项目名称:smarttypes,代码行数:32,代码来源:graphlab_to_smarttypes.py


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