机器学习 AUC ROC 曲线评价指标

FreeGuideOnline 42阅读 2026-07-08

python from sklearn.metrics import roc_auc_score, roc_curve

y_true = [0, 0, 1, 1] # 真实标签 y_scores = [0.1, 0.4, 0.35, 0.8] # 预测概率

auc = roc_auc_score(y_true, y_scores) fpr, tpr, thresholds = roc_curve(y_true, y_scores)

print(f'AUC: {auc:.3f}')