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)
更多回答
我是一名优秀的程序员,十分优秀!