cannot import name 'plot_confusion_matrix' from 'sklearn.metrics'
时间: 2023-10-12 10:05:13 浏览: 269
sklearn-SVM.zip_-baijiahao_AUC_plot_hyperplane_sklearn_sklearn s
The error message "cannot import name 'plot_confusion_matrix' from 'sklearn.metrics'" usually occurs when you are trying to use the "plot_confusion_matrix" function from the "sklearn.metrics" module but it is not available in your version of scikit-learn.
The "plot_confusion_matrix" function was added in scikit-learn version 0.22, so if you are using an older version of scikit-learn, you will need to upgrade to version 0.22 or higher to use this function.
To upgrade scikit-learn, you can use pip, the Python package installer, by running the following command in your terminal or command prompt:
```
pip install --upgrade scikit-learn
```
After upgrading scikit-learn, you should be able to import the "plot_confusion_matrix" function from the "sklearn.metrics" module without any issues.
阅读全文