I am not able to import Porter; I am facing
ModuleNotFoundError: No module named 'sklearn.tree.tree' error
Code:
from sklearn_porter import Porter
Error message:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-19-574fff36293e> in <module>
----> 1 from sklearn_porter import Porter
2
3 porter = Porter(clf, language='c')
4 output = porter.export()
5
~/.local/lib/python3.8/site-packages/sklearn_porter/__init__.py in <module>
7 from json import load
8
----> 9 from sklearn_porter.Porter import Porter
10
11
~/.local/lib/python3.8/site-packages/sklearn_porter/Porter.py in <module>
8
9 from sklearn.metrics import accuracy_score
---> 10 from sklearn.tree.tree import DecisionTreeClassifier
11 from sklearn.ensemble.weight_boosting import AdaBoostClassifier
12 from sklearn.ensemble.forest import RandomForestClassifier
ModuleNotFoundError: No module named 'sklearn.tree.tree'
I guess your version of sklearn
is recent (0.20 or newer). In this case the import fails. You could downgrade sklearn
, but this is not suggested. Or you can edit the imports in sklearn_porter/Porter.py
by hand. Here are the lines to change .
There is a related pull request on GitHub to close this issue in the future.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.