There seems to be something wrong with my code implementation of the evaluation metric ndcg
def ndcg(preds: dict,test_gd: dict, topN=50): “””NDCG@topN Args: preds (dict): preds[user] = [item1,item2,…] test_gd (dict): test_gd[user] = [item1,item2,…] topN (int, optional): topn. Defaults to 50. Returns: dict: ndcg@topN “”” total_recall = 0.0 total_ndcg = 0.0 for user in test_gd.keys(): recall = 0 dcg = 0.0 item_list = test_gd[user] for no, item_id in enumerate(item_list): if item_id in […]