cannot import name 'plot_confusion_matrix' from 'sklearn.metrics'
时间: 2023-09-02 21:08:48 浏览: 385
sklearn-SVM.zip_-baijiahao_AUC_plot_hyperplane_sklearn_sklearn s
The error message "cannot import name 'plot_confusion_matrix' from 'sklearn.metrics'" suggests that the plot_confusion_matrix function cannot be found in the sklearn.metrics module. This function was introduced in version 0.22 of scikit-learn, so you may need to upgrade your scikit-learn package to the latest version.
You can upgrade scikit-learn using pip by running the following command in your terminal or command prompt:
```
pip install --upgrade scikit-learn
```
After upgrading scikit-learn, you can import the plot_confusion_matrix function from sklearn.metrics as follows:
```
from sklearn.metrics import plot_confusion_matrix
```
阅读全文