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

ModuleNotFoundError: No module named 'sklearn.utils.testing' #347

Open
Rushi21-kesh opened this issue Apr 17, 2021 · 6 comments
Open

ModuleNotFoundError: No module named 'sklearn.utils.testing' #347

Rushi21-kesh opened this issue Apr 17, 2021 · 6 comments

Comments

@Rushi21-kesh
Copy link

  • Lazy Predict version: '0.2.7'
  • Python version: 3.8.0
  • Sklearn version : 0.21.3 / 0.23.1 / 0.24.1
  • Operating System: Windows 10

Description

I'm trying to Import LazyRegressor from lazypredict.Supervised

But while importing I'm getting an error " ModuleNotFoundError: No module named 'sklearn.utils.testing' ". I try it by installing Sklearn version: 0.21.3 / 0.23.1 / 0.24.1 but the same error is raised everytime ( I did all this in new env )

What I Did

import lazypredict
from lazypredict.Supervised import LazyRegressor

Output :
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-12-340b76a5a8e6> in <module>
      1 import lazypredict
----> 2 from lazypredict.Supervised import LazyRegressor

d:\ds env\python\lib\site-packages\lazypredict\Supervised.py in <module>
     14 from sklearn.preprocessing import StandardScaler, OneHotEncoder
     15 from sklearn.compose import ColumnTransformer
---> 16 from sklearn.utils.testing import all_estimators
     17 from sklearn.base import RegressorMixin
     18 from sklearn.base import ClassifierMixin

ModuleNotFoundError: No module named 'sklearn.utils.testing'
@adarshchbs
Copy link

Change the sklearn version to 23.x instead of 24.x.

@WOKNz
Copy link

WOKNz commented Apr 29, 2021

from sklearn.utils.testing import all_estimators to
from sklearn.testing import all_estimators

@sanromd
Copy link

sanromd commented May 14, 2021

I came across the same problem that @Rushi21-kesh mentioned. The ModuleNotFoundError arises when removing classifiers and regressors. I solved the issue by modifying the firs couple of lines in Supervised.py. @shankarpandala Instead of building a list of tupples (estimator_name, sklearn.moduleX) to remove, create a list with estimator_name to remove, then use it in the list comprehension to remove them. This effectively makes the code run with sklearn 0.23.x and 0.24.x

removed_classifiers = [
    "ClassifierChain",
    "ComplementNB",
    "GradientBoostingClassifier",
    "GaussianProcessClassifier",
    "HistGradientBoostingClassifier",
    "MLPClassifier",
    "LogisticRegressionCV", 
    "MultiOutputClassifier", 
    "MultinomialNB", 
    "OneVsOneClassifier",
    "OneVsRestClassifier",
    "OutputCodeClassifier",
    "RadiusNeighborsClassifier",
    "VotingClassifier",
]

removed_regressors = [
    "TheilSenRegressor",
    "ARDRegression", 
    "CCA", 
    "IsotonicRegression", 
    "StackingRegressor",
    "MultiOutputRegressor", 
    "MultiTaskElasticNet", 
    "MultiTaskElasticNetCV", 
    "MultiTaskLasso", 
    "MultiTaskLassoCV", 
    "PLSCanonical", 
    "PLSRegression", 
    "RadiusNeighborsRegressor", 
    "RegressorChain", 
    "VotingRegressor", 
]
CLASSIFIERS = [est for est in all_estimators() if 
               (issubclass(est[1], ClassifierMixin) and (est[0] not in removed_classifiers))]

REGRESSORS = [est for est in all_estimators() if 
              (issubclass(est[1], RegressorMixin) and (est[0] not in removed_regressors))]

@Josephsmurph13
Copy link

Apologies, I am very new to python. I am getting the same error ModuleNotFoundError: No module named 'sklearn.utils.testing'.

Is this issue likely to be fixed in a new version soon? I am unable to install previous versions of lazypredict.

Do we know if editing the Supervised.py under the lazypredict site-packages folder fixes this? If so please could someone share the full contents of the file to update?

@naveen-marthala
Copy link

I have the same error and I am using sklearn 0.24.x.

user@name::~$ pip freeze | grep -i 'learn'
imbalanced-learn==0.7.0
scikit-learn==0.24.2
sklearn==0.0
umap-learn==0.5.1
user@name::~$ pip freeze | grep -i 'lazy'
lazypredict==0.2.9

@am-official
Copy link

Those who are facing ModuleNotFoundError: No module named 'sklearn.utils.testing'

import sklearn
estimators = sklearn.utils.all_estimators(type_filter=None)
for name, class_ in estimators:
    if hasattr(class_, 'predict_proba'):
        print(name)

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

No branches or pull requests

7 participants