-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scikit-learn-0.24.1: ModuleNotFoundError: No module named 'sklearn.tree.tree' #82
Comments
This one need to freeze version of scikit-learn. |
thanks, that was extremely helpful.. i was unable to proceed via 0.22; i am on WinPython |
Is there a way to incorporate these changes into the repo? I've made the changes locally, but I'm wondering how these updates could be made into the source code on here. What's the procedure for that? |
@nok please make changes of the import in the porter.py, or just state your module as deprecated if you are no longer updating it. |
Here is a monkey patch that works for me with Python 3.10.4 and sklearn==1.2.1 Just put this at the top of your source file and you will not need to patch the sklearn_porter source import sklearn
import sklearn.tree
import sklearn.ensemble
import sklearn.svm
import sklearn.neighbors
import sklearn.neural_network
import json
import sys
sys.modules["sklearn.tree.tree"] = sklearn.tree
sys.modules["sklearn.ensemble.weight_boosting"] = sklearn.ensemble
sys.modules["sklearn.ensemble.forest"] = sklearn.ensemble
sys.modules["sklearn.svm.classes"] = sklearn.svm
sys.modules["sklearn.neighbors.classification"] = sklearn.neighbors
sys.modules["sklearn.neural_network.multilayer_perceptron"] = sklearn.neural_network
json.origional_load = json.load
json.load = lambda f, **kwargs: json.origional_load(f)
from sklearn_porter import Porter |
I'm using porter 0.7.4. I updated to scikit-learn 0.24.1 (using conda) and got the error:
ModuleNotFoundError: No module named 'sklearn.tree.tree'
It seems like the imports have changed??
I got it running by changing imports:
in init.py
from sklearn.tree import DecisionTreeClassifier
in Porter.py:
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.svm import LinearSVC
from sklearn.svm import SVC
from sklearn.svm import NuSVC
from sklearn.neighbors import KNeighborsClassifier
and later changing (in the code in a if-version) a couple places
sklearn.neural_network.multilayer_perceptron \ -> from sklearn.neural_network \
The text was updated successfully, but these errors were encountered: