gpt4 book ai didi

How to use NDCG for multiclass classification problem(如何使用NDCG解决多类分类问题)

转载 作者:bug小助手 更新时间:2023-10-24 17:10:58 35 4
gpt4 key购买 nike



I have 20 different labels and they are [0, 1, 2, ..., 20]. Let's say that I have 5 samples and their predictions are: [2,1,17,9,6] and true_labels are [3,2,15,7,4].

我有20个不同的标签,它们是[0,1,2,...,20]。假设我有5个样本,他们的预测是:[2,1,17,9,6],而True_Labels是[3,2,15,7,4]。


from sklearn.metrics import ndcg_score
predictions = [2,1,17,9,6]
true_labels = [3,2,15,7,4]
ndcg = ndcg_score(references], predictions)

The code given below throws this error:

下面给出的代码抛出此错误:


ValueError: Only ('multilabel-indicator', 'continuous-multioutput', 'multiclass-multioutput') formats are supported. Got multiclass instead

更多回答
优秀答案推荐

Followed the docs: y_true array-like of shape (n_samples, n_labels)

跟随文档:形状的Y_TRUE类似数组(n_Samples,n_Labels)


from sklearn.metrics import ndcg_score
import numpy as np
predictions = np.asarray([[2,1,17,9,6]])
true_labels = np.asarray([[3,2,15,7,4]])
ndcg = ndcg_score(true_labels, predictions)

更多回答

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