diff --git a/pltcode b/pltcode new file mode 100644 index 0000000000000000000000000000000000000000..3b61db0615f3960f719465b3d39fb7db6026824b --- /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()