gpt4 book ai didi

python - sklearn 中 nDCG 的输入

转载 作者:太空宇宙 更新时间:2023-11-03 11:17:12 25 4
gpt4 key购买 nike

我无法理解 sklearn nDcg 的输入格式:http://sklearn.apachecn.org/en/0.19.0/modules/generated/sklearn.metrics.ndcg_score.html

目前我有以下问题:我有多个查询,每个查询的排名概率都已成功计算。但现在的问题是为我想使用 sklearn nDcg 的测试集计算 nDCG。链接上给出的例子

>>> y_true = [1, 0, 2]
>>> y_score = [[0.15, 0.55, 0.2], [0.7, 0.2, 0.1], [0.06, 0.04, 0.9]]
>>> ndcg_score(y_true, y_score, k=2)
1.0

根据站点,y_true 是基本事实,y_score 是概率。所以以下是我的问题:

  1. 此示例是针对一个查询还是多个查询?
  2. 如果这只是一个查询,那么 y_true 代表什么:原始排名?
  3. 如果这是针对单个查询,为什么我们有多个输入概率?
  4. 如何将此方法应用于多个查询及其结果概率?

最佳答案

您可以将其视为类似于多类分类问题。

所以回答你的问题

  1. Is this example for just one query or multiple queries?

一次查询

  1. If this is for just one query then what does y_true represents: original rankings?

我将其称为文档的相关性标签,因为它可能具有重复值。

  1. If this is for a single query and why we have multiple input probabilites?

y_score 是文档属于某个类别的概率分布。在您的示例中 y_score = [[0.15, 0.55, 0.2], [0.7, 0.2, 0.1], [0.06, 0.04, 0.9]] 表示第 0 个文档属于第 1 类(0.55 是最大值),第一个文档属于 0 类(0.7 是最大值),第二个文档属于 2 类(0.9 是最大值)。缺少文档,示例也具有误导性。如果有四个文件就更好了。

  1. How this method can be applied to multiple queries and their resultant probabilites?

然后,您可以对多个查询中每个查询的 nDCG 分数进行平均。

关于python - sklearn 中 nDCG 的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49989128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com