def calculate_recommendations(output_filename, model_name="<STR_LIT>"):
<EOL>artists, users, plays = get_lastfm()<EOL>model = get_model(model_name)<EOL>if issubclass(model.__class__, AlternatingLeastSquares):<EOL><INDENT>logging.debug("<STR_LIT>")<EOL>plays = bm25_weight(plays, K1=<NUM_LIT:100>, B=<NUM_LIT>)<EOL>model.approximate_similar_items = False<EOL><DEDENT>plays = plays.tocsr()<EOL>logging.debug("<STR_LIT>", model_name)<EOL>start = time.time()<EOL>model.fit(plays)<EOL>logging.debug("<STR_LIT>", model_name, time.time() - start)<EOL>start = time.time()<EOL>user_plays = plays.T.tocsr()<EOL>with tqdm.tqdm(total=len(users)) as progress:<EOL><INDENT>with codecs.open(output_filename, "<STR_LIT:w>", "<STR_LIT:utf8>") as o:<EOL><INDENT>for userid, username in enumerate(users):<EOL><INDENT>for artistid, score in model.recommend(userid, user_plays):<EOL><INDENT>o.write("<STR_LIT>" % (username, artists[artistid], score))<EOL><DEDENT>progress.update(<NUM_LIT:1>)<EOL><DEDENT><DEDENT><DEDENT>logging.debug("<STR_LIT>",  time.time() - start)<EOL>
Generates artist recommendations for each user in the dataset