sklearn计算召回率等评价指标时,比较元素的顺序
代码体现
from sklearn.metrics import recall_score
y_true = [a, 'd', 'b', 'b', 'b', 'c' , 0, 1, 2, 2, 1, 2]
y_pred = [1, 'd', 'b', 'c', 'c', 'c', 1, 1, 0, 2, 0, 1]
print(recall_score(y_true, y_pred, average=None))
顺序为:数字>变量>string
上例中string在列表中顺序为d、b、c,在比较时调整为b、c、d