关于 f1_score 和 roc_auc_score
使用sklearn
中f1_score
过程中的警告
- 警告信息:UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples.
'precision', 'predicted', average, warn_for)
- 这个警告信息是说在所有的真实标签中存在标签没有被预测过,比如说:y_true = [0,2,1,3],y_pred = [2,2,3,3]
使用sklearn
中roc_auc_score
过程中的错误
- 错误信息:ValueError: Only one class present in y_true. ROC AUC score is not defined in that case.
- 这个错误是说在 y_true 中有一列只有一种类别,比如:
y_true = [[0, 1, 0]
[1, 0, 0]
[1, 0, 0]]
其中最后一列只有 0 也就是只有一个类别。将y_true
变回直接的数字标签形式,即 [1,0,0],这个错误消失了
原文地址:https://www.cnblogs.com/xxBryce/p/13046434.html