0

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'
desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • This is a version issue, [see](https://stackoverflow.com/questions/66029751/modulenotfounderror-no-module-named-sklearn-tree-tree). – RJ Adriaansen Mar 05 '21 at 08:59

1 Answers1

0

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.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
mosc9575
  • 5,618
  • 2
  • 9
  • 32