Concerning the code below (extract from recommendation worker):
write the results to file
if len(user_ids) > 0:
item_id = str(i) + "\t"
fp.write(item_id)
for j in range(0, len(user_ids)):
user_id = str(user_ids[j][0]) + ","
fp.write(user_id)
user_id = str(user_ids[-1][0]) + "\n"
fp.write(user_id)
fp.flush()
At the end, you write the same user twice, don't you ?
Indeed user_ids[-1][0] and user_ids[len(user_ids)-1] are the same. And with "j in range(0,len(user_ids))", the last term is j=len(user_ids)-1
So, you should loop for j in range(0, len(user_ids)-1)?
I have rapidly check in my output file (from your program) : the same user appear twice at the end.
Hi,
Concerning the code below (extract from recommendation worker):
write the results to file
At the end, you write the same user twice, don't you ? Indeed user_ids[-1][0] and user_ids[len(user_ids)-1] are the same. And with "j in range(0,len(user_ids))", the last term is j=len(user_ids)-1 So, you should loop for j in range(0, len(user_ids)-1)?
I have rapidly check in my output file (from your program) : the same user appear twice at the end.
BR.