I wish to add on text to each cell of a confusion matrix object from scikit-learn. More specifically, I wish to put True Positive in the top left cell, False Positive in the top right cell etc. Is there a easy to way to do so, or do I have to use annotate and specify the coordinates?
fig, (ax1, ax2) = plt.subplots(1, 2)
fig.tight_layout
cm_benign = metrics.ConfusionMatrixDisplay.from_predictions(
y_true, y_pred, ax=ax1, labels=["benign", "malignant"], colorbar=False
)
ax1.set_title("Confusion Matrix (Benign as +)")
cm_malignant = metrics.ConfusionMatrixDisplay.from_predictions(
y_true, y_pred, ax=ax2, labels=["malignant", "benign"], colorbar=False
)
ax2.set_title("Confusion Matrix (Malignant as +)")
fig.subplots_adjust(wspace=0.8)
plt.show();