本文整理汇总了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
示例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