【发布时间】:2021-03-13 01:08:34
【问题描述】:
我正在尝试使用 sklearn 混淆矩阵类来绘制混淆矩阵。
这是我使用的代码:
from sklearn.metrics import roc_curve, auc, plot_confusion_matrix
import matplotlib.pyplot as plt
disp = plot_confusion_matrix(self.g_cv.best_estimator_ , self.test_X, self.test_Y,
cmap=plt.cm.Blues)
plt.title('Confusion Matrix')
plt.plot(disp)
这是基于 Sklearn 网站上的这个例子:
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.plot_confusion_matrix.html
但是当我调用它时我得到一个错误。
TypeError: float() argument must be a string or a number, not 'ConfusionMatrixDisplay'
它确实会绘制它,但也会引发此错误。正在绘制的返回对象是否有问题?
【问题讨论】:
标签: python matplotlib scikit-learn