def recommend(self, userid, user_items,<EOL>N=<NUM_LIT:10>, filter_already_liked_items=True, filter_items=None, recalculate_user=False):
if userid >= user_items.shape[<NUM_LIT:0>]:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>items = N<EOL>if filter_items:<EOL><INDENT>items += len(filter_items)<EOL><DEDENT>indices, data = self.scorer.recommend(userid, user_items.indptr, user_items.indices,<EOL>user_items.data, K=items,<EOL>remove_own_likes=filter_already_liked_items)<EOL>best = sorted(zip(indices, data), key=lambda x: -x[<NUM_LIT:1>])<EOL>if not filter_items:<EOL><INDENT>return best<EOL><DEDENT>liked = set(filter_items)<EOL>return list(itertools.islice((rec for rec in best if rec[<NUM_LIT:0>] not in liked), N))<EOL>
returns the best N recommendations for a user given its id