No Module Name 'sklearn.forest.ensemble'
Solution 1:
sklearn.ensemble.forest
was renamed to sklearn.ensemble._forest
in 437ca05 on Oct 16, 2019. You need to install an older sklearn
. Try version 0.21.3 released on Jul 30, 2019:
pip install -U scikit-learn==0.21.3
Please be warned that the authors provided wheels up to Python 3.7. For 3.8 or 3.9 you will need to compile from sources.
Solution 2:
The answer above is correct,
sklearn.ensemble.forest
is renamed to sklearn.ensemble._forest
This problem persist with more libraries that depend on sklearn, therefore I want to provide an additional solution that universally for most of these packages.
In your case your library is called face_detector
, but you can replace it with any library name when you encounter this issue with versioning of scikit-learn (as well as with other libraries).
Locate the directory of the library:
import face_detector print(face_detector.\_\_file__)
Open the file in any text editor, in your case the name of the library file would be
face_detector.py
Out-comment the old import and replace with the new import.
Comment out the import for the old versions of sklearn and add the new import statement
# from sklearn.ensemble.forest import ForestClassifier, ForestRegressorfrom sklearn.ensemble._forest import ForestClassifier, ForestRegressor
Safe and enjoy, you just fixed a dependency issue! This solution will work for most libraries and is even less work than installing a different version of sklearn. In case it does not work, you can still install and older version as suggested in the other answer.
Note: This solution can be easily modified to trace and fix dependency issues for other library dependencies than sklearn. As long as the function itself did not change in input and output parameters, fixing renaming issues is an easy way to fix broken dependencies.
Solution 3:
maybe your model is too old. use:
pip install scikit-learn==0.22
to install the old version of sklearn.
Post a Comment for "No Module Name 'sklearn.forest.ensemble'"