召回评估
本次task多路召回任务比较陌生,代码量比较大,还需要一些时间理解。因此我选择针对一些重点内容逐一查阅资料来建立更深刻的理解。先从召回评估开始,逐步窥探召回层的相关内容。
todo 目前整理了有哪些方法,后续再细探每种评估方法的优缺点,并将本次多路召回算法中的评估方法替换成其他评估算法来寻找差别
为什么进行召回评估
当前推荐系统的模型并不是端到端的,通常包括召回层与排序层,召回层负责将大量数据快速缩小,为排序层提供快速精简且有效的输入,因此,召回的结果决定了排序层模型性能的上限,因此需要对召回结果有合理的评估方式。
本次DW-RuyiLuo给出的代码中召回评估的代码如下,这份代码中应该是使用了HR评估
# 依次评估召回的前10, 20, 30, 40, 50个文章中的击中率
def metrics_recall(user_recall_items_dict, trn_last_click_df, topk=5):
last_click_item_dict = dict(zip(trn_last_click_df['user_id'], trn_last_click_df['click_article_id']))
user_num = len(user_recall_items_dict)
for k in range(10, topk+1, 10):
hit_num = 0
for user, item_list in user_recall_items_dict.items():
# 获取前k个召回的结果
tmp_recall_items = [x[0] for x in user_recall_items_dict[user][:k]]
if last_click_item_dict[user] in set(tmp_recall_items):
hit_num += 1
hit_rate = round(hit_num * 1.0 / user_num, 5)
print(' topk: ', k, ' : ', 'hit_num: ', hit_num, 'hit_rate: ', hit_rate, 'user_num : ', user_num)
topK召回评估的方法
- NS-Recall 与 NS-Precesion
参考:
Cremonesi, P., Koren, Y. & Turrin, R. Performance of recommender algorithms on top-n recommendation tasks. in Proceedings of the fourth ACM conference on Recommender systems - RecSys ’10 39 (ACM Press, 2010). doi:10/btps2w.
NS-Recall:
recall ( N ) = # h i t s ∣ T ∣ \operatorname{recall}(N)=\frac{\# \mathrm{hits}}{|T|} recall(N)=