Если вы проверите источник для sklearn.metrics.plot_confusion_matrix
, вы сможете увидеть, как обрабатываются данные для создания графика. Затем вы можете повторно использовать конструктор ConfusionMatrixDisplay
и построить собственную матрицу путаницы.
import matplotlib.pyplot as plt
from sklearn.metrics import ConfusionMatrixDisplay
cm = [0.612, 0.388, 0.228, 0.772] # your confusion matrix
ls = [0, 1] # your y labels
disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=ls)
disp.plot(include_values=include_values, cmap=cmap, ax=ax, xticks_rotation=xticks_rotation)
plt.show()