评估目标之RMSE,MAP,NDCG

今天终于得空写点最近看的东西。 最近在看排序算法lambadarank,先写下几种evaluation metrics

1. MSE

MSE(mean square error, 均方误差)是预测值与真实值差的平方的期望:
这里写图片描述

2. RMSE

RMSE(root mean square error, 均方根误差)是MSE的算数平方根
这里写图片描述
RMSE在常在回归问题中用作loss function

3. MAP

MAP(mean average precision)是常用于query模型的评估标准。
MAP与NDCG参考 原文http://fastml.com/evaluating-recommender-systems/ 及译文 http://www.csdn.net/article/2015-09-07/2825630
原文中说,MAP与NDCG的主要区别是在衡量query与返回文档的相关性时,MAP使用二值(1表示相关,0表示不相关),而NDCG允许相关值是实数值。
AP(average precision)是一次query的评估值。
评估目标之RMSE,MAP,NDCG_第1张图片
其中,N(rel)是指与query相关的文档数量; n表示query返回的doc;rel(k)表示文档k与query的相关值(非1即0); P(k)是指前k个文档的准确率,即
这里写图片描述
其中,mk是前k篇文档中与query相关的doc数量。

例如query1相关的doc共4个,在排序模型预测中这4个doc的index是1,2,4,7,则 这里写图片描述
query2 三个相关doc位于1, 3, 5,AP(query2) = 0.45

MAP表示所有query的AP的均值,评估目标之RMSE,MAP,NDCG_第2张图片

上例子中,
MAP = (AP(query1) + AP(query2)) / 2 = 0.64
注: MAP与NDCG一样,计算过程中考虑排序列表中doc的序号。

4. NDCG

DCG:

Discounted cumulative gain (DCG) is a measure of ranking quality. In information retrieval, it is often used to measure effectiveness of web search engine algorithms or related applications. Using a graded relevance scale of documents in a search engine result set, DCG measures the usefulness, or gain, of a document based on its position in the result list. The gain is accumulated from the top of the result list to the bottom with the gain of each result discounted at lower ranks.

其中Discounted是折算、衰减的意思,这里是指排序列表中每个doc的得分会被其位置序号衰减。 一次query,结果列表 中1-p位置的DCG计算公式:
这里写图片描述
在网页检索、数据比赛(例如Kaggle)中可以使用更加强调文档相关性的公式:
这里写图片描述

NDCG

Search result lists vary in length depending on the query. Comparing a search engine's performance from one query to the next cannot be consistently achieved using DCG alone, so the cumulative gain at each position for a chosen value of p should be normalized across queries. This is done by sorting all relevant documents in the corpus by their relative relevance, producing the maximum possible DCG through position p, also called Ideal DCG (IDCG) through that position. For a query, the normalized discounted cumulative gain, or nDCG, is computed as:

这里写图片描述
上述公式是计算一次query中返回列表位置p的ndcg,即位置1-p的累积折算增益。
其中,IDCG是搜索结果按照相关性排序后的最大的DCG:
这里写图片描述
其中|REL|是排序后的列表。

wiki上例子:
一次query,返回D1, D2, D3, D4, D5,D6, 相关性为:3,2,3,0,1,2
CG:
这里写图片描述
调整doc的顺序并不改变CG
看下DCG:
评估目标之RMSE,MAP,NDCG_第3张图片

这里写图片描述
调整doc的位置会改变DCG。最理想的DCG即IDCG是按照相关性排序:3,3,2,2,1,0,计算得到IDCG6 = 7.141,则归一化结果:
NDCG6 = 6.861 / 7.141 = 0.961

你可能感兴趣的:(机器学习,推荐系统)