Skip to content
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

Open
inielse opened this issue Mar 4, 2021 · 5 comments

Comments

@inielse
Copy link

inielse commented Mar 4, 2021

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 \

@dujtep-airtech
Copy link

This one need to freeze version of scikit-learn.
run cmd with "pip3 install scikit-learn==0.22" and freeze with "python3 -m pip freeze - scikit-learn==0.22"

@smsti
Copy link

smsti commented Jun 20, 2021

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 \

thanks, that was extremely helpful.. i was unable to proceed via 0.22; i am on WinPython

@mayowaosibodu
Copy link

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 \

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?

@outcastdreamer
Copy link

@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.

@jkfurtney
Copy link

jkfurtney commented Jun 8, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants