ImportError: cannot import name 'plot_tree' from 'sklearn.tree'

Question:

Import error when importing plot_tree from sklearn

after doing pip install sklearn

Error-Log:

from sklearn.tree import DecisionTreeClassifier, plot_tree

ImportError: cannot import name 'plot_tree' from 'sklearn.tree'
Asked By: Aqua 4

||

Answers:

Install scikit-learn

Fix:

pip install scikit-learn
Answered By: Aqua 4

Plot tree is available after sklearn version > 0.21.

pip install --upgrade sklearn

could help but if it isn’t you have to upgrade the whole python version.

I had the same issue on 3.6.7 python
and solve it by installing 3.7.7.

Answered By: MosQuan