From f95d65b303484206e0150d6731630957fd993a3c Mon Sep 17 00:00:00 2001 From: yl1r22 <yl1r22@soton.ac.uk> Date: Tue, 6 Jun 2023 16:40:13 +0000 Subject: [PATCH] Add new file --- pltcode | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 pltcode diff --git a/pltcode b/pltcode new file mode 100644 index 0000000..3b61db0 --- /dev/null +++ b/pltcode @@ -0,0 +1,30 @@ +import matplotlib.pyplot as plt +import seaborn as sns +from sklearn.metrics import confusion_matrix + +# 假设 y_test 是真实标签,y_pred 是预测标签 +conf_mat = confusion_matrix(y_test, y_pred) + +plt.figure(figsize=(10, 7)) +sns.heatmap(conf_mat, annot=True, fmt='d', cmap='YlGnBu') +plt.xlabel('Predicted') +plt.ylabel('Actual') +plt.show() + + +from sklearn.metrics import roc_curve, auc + +# 假设 y_test 是真实标签,y_score 是预测得分 +fpr, tpr, _ = roc_curve(y_test, y_score) +roc_auc = auc(fpr, tpr) + +plt.figure() +plt.plot(fpr, tpr, color='darkorange', lw=2, label='ROC curve (area = %0.2f)' % roc_auc) +plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--') +plt.xlim([0.0, 1.0]) +plt.ylim([0.0, 1.05]) +plt.xlabel('False Positive Rate') +plt.ylabel('True Positive Rate') +plt.title('Receiver Operating Characteristic') +plt.legend(loc="lower right") +plt.show() -- GitLab