簡體   English   中英

繪制混淆矩陣

[英]Plotting confusion matrix

我正在嘗試通過以下代碼段使用scikitplot.metrics.plot_confusion_matrix來 plot 混淆矩陣-

import scikitplot as skplt

Y_Test = [1, 0, 1, 0, 1, 1, 0, 1, 1 ,1 ,1, 1, 0, 0 ,0];
Y_Pred = [1, 0, 0, 0, 1, 1, 0, 1, 1 ,1 ,1, 1, 1, 0 ,0];
cm = skplt.metrics.plot_confusion_matrix(Y_Test,Y_Pred,normalize=True, text_fontsize = 'large')

但是,我並沒有完全得到如圖所示的預期結果(不知何故,文本與軸重疊)。 我怎樣才能使它整潔干凈?

在此處輸入圖像描述

首先檢查安裝的 matplotlib 的版本。 問題在於 scikitplot 在內部使用的“imshow”function。 在修復之前,請卸載當前的 matplotlib 版本並使用以下命令安裝“3.0.3”版本。

pip uninstall matplotlib
pip install matplotlib=='3.0.3'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM