ROC and PR Curves
1. ROC 曲線(Receiver Operating Characteristic Curve)
特點:
from sklearn.metrics import roc_curve, roc_auc_score
import matplotlib.pyplot as plt
fpr, tpr, _ = roc_curve(y_true, y_prob)
auc = roc_auc_score(y_true, y_prob)
plt.plot(fpr, tpr, label=f"ROC curve (AUC = {auc:.2f})")
plt.plot([0, 1], [0, 1], linestyle='--')
plt.xlabel("False Positive Rate")
plt.ylabel("True Positive Rate")
plt.legend()
plt.title("ROC Curve")
plt.show()2. PR 曲線(Precision-Recall Curve)
特點:
3. 選擇建議
情境
建議使用
4. 總結
Last updated