def check_predict(_):
print("#", end="")
sys.stdout.flush()
max_b = 0
user_indices = random.choices(range(len(users)), k=N_PER_CHUNK)
repo_indices = random.choices(range(len(repos)), k=N_PER_CHUNK)
for index in range(N_PER_CHUNK):
if B[user_indices[index], repo_indices[index]] == 1.0: # Link already exists.
continue
new_b = U[user_indices[index], :] @ V[:, repo_indices[index]]
if new_b > max_b:
max_b = new_b
user_id = users[user_indices[index]]
repo_id = repos[repo_indices[index]]
best_pred = (user_id, user_id2name[user_id],
repo_id, repo_id2name[repo_id],
new_b)
# print(best_pred)
return best_pred
评论列表
文章目录