I am currently trying to follow this scikit-learn example to plot a confusion matrix for a classifier I have. However, I get an import error whenever I try and import with this line from my terminal:
>>> from sklearn.metrics import plot_confusion_matrix
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'plot_confusion_matrix' from 'sklearn.metrics' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/metrics/__init__.py)
The main goal is to get this to work on a jupyter notebook (currently being run on Google Colab). The same import line gets this error:
ImportError: cannot import name 'plot_confusion_matrix'
Note that I have re-updated my sklearn, scipy, and numpy on my terminal and gotten the same error. Here is the documentation for plot_confusion_matrix.
The answer: I was updating my sklearn instead of scikit-learn. This module is only available starting at 0.22, and I was running 0.21.2. Thanks @VivekKumar!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With