module ‘sklearn.metrics’ has no attribute ‘plot_confusion_matrix’
分类:Python
这个问题可能是由于你正在使用的 scikit-learn 版本中并没有 plot_confusion_matrix
函数导致的。这个函数最早是在 scikit-learn 0.22 版本中引入的,如果你的 scikit-learn 版本低于这个版本,就会出现这个错误。
如果你的 scikit-learn 版本低于 0.22,可以尝试升级 scikit-learn 到最新版本来解决这个问题。你可以使用以下命令升级 scikit-learn:
pip install --upgrade scikit-learn
如果你的 scikit-learn 版本已经高于 0.22,那么这个问题可能是由于你导入的方式不正确。你可以尝试使用以下方式导入 plot_confusion_matrix
函数:
from sklearn.metrics import plot_confusion_matrix