lazypredict icon indicating copy to clipboard operation
lazypredict copied to clipboard

Lazypredict package should check for dependencies at installation

Open LaurentBerder opened this issue 4 years ago • 18 comments

Hi,

I wanted to give your package a try, but can't. A bit of description of my setup:

  • Operating System: Google Colab Notebook (Linux)
  • Python 3.6.9
  • lazypredict==0.2.7
  • scikit-learn==0.24.0

I'm getting an error just by importing your package.

from lazypredict.Supervised import LazyRegressor
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-85-a096f5bd7a1d> in <module>()
----> 1 from lazypredict.Supervised import LazyRegressor

/usr/local/lib/python3.6/dist-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'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

It seems to be a discrepancy between the version of SciKit-Learn I have and the one that LazyPredict expects, since the architecture of sklearn is different.

Shouldn't you try to make sure that the expected versions of dependency packages are installed ?

LaurentBerder avatar Feb 04 '21 12:02 LaurentBerder

second this

qemtek avatar Feb 05 '21 14:02 qemtek

Hi guys, thanks for opening this issue. Indeed, the current version of lazypredict requires that you use the scikit-learn==0.23.1, because a couple things have changed after the sckit-learn upgrade to version 0.24.

We need to update the lazypredict support of scikit-lean.

I'm planning to do this on the next weeks, but if any of you wanted to give a try, please, let me know and go ahead.

brendalf avatar Feb 06 '21 15:02 brendalf

Sorry @brendalf, I admit I wouldn't know how. I did, however, give a try with scikit-learn==0.23.1, and hit another issue with scipy version, as it seems only version scipy==1.6.0 is supported. Which assumes only python 3.6 at the highest (I was trying out with python 3.9).

LaurentBerder avatar Feb 08 '21 15:02 LaurentBerder

Go to Supervised.py and change this line

from sklearn.utils.testing import all_estimators

to

from sklearn.utils import all_estimators

I did this in my environment and it works fine now.

asad-mahmood avatar Feb 09 '21 01:02 asad-mahmood

Go to Supervised.py and change this line

from sklearn.utils.testing import all_estimators

to

from sklearn.utils import all_estimators

I did this in my environment and it works fine now.

How do you go to Supervised.py?

agupta004 avatar Jun 08 '21 19:06 agupta004

@agupta004 should be in your virtual environment folder: /envs/<your_environment_name>/lib/python/site-packages/lazypredict/Supervised.py

dmirakyan avatar Jun 21 '21 01:06 dmirakyan

Go to Supervised.py and change this line

from sklearn.utils.testing import all_estimators

to

from sklearn.utils import all_estimators

I did this in my environment and it works fine now.

This is not the only import causing error. There are many others. I tried fixing them but end up giving up.

rupesh-dharme avatar Aug 31 '21 16:08 rupesh-dharme

If anyone still has this issue, to fix this, I overwrote the contents of ../python3.9/site-packages/lazypredict/Supervised.py with the contents of the pull request where this issue is fixed but not yet merged https://github.com/shankarpandala/lazypredict/blob/e6e59f0053208326e90e65b67978122bbaeacace/lazypredict/Supervised.py Then I was able to successfully import it with scikit-learn 0.24.2

ghost avatar Sep 26 '21 13:09 ghost

I edited the Supervisor.py file as suggested by agupta004, and now I get: "Traceback (most recent call last): File "D:/Bioinformatics/Python/Python_for_Bioinformatics_04.py", line 8, in from lazypredict.Supervised import LazyRegressor File "C:\Users\xxxx\AppData\Local\Programs\Python\Python39\lib\site-packages\lazypredict\Supervised.py", line 22, in import xgboost ModuleNotFoundError: No module named 'xgboost'"

How can we fix this?

My python is python 3.9, on Windows 10, and my python environment looks like: C:\WINDOWS\system32>pip freeze altgraph==0.17 asgiref==3.3.1 astroid==2.4.2 attrs==21.2.0 backcall==0.2.0 bcrypt==3.2.0 bsddb3 @ file:///C:/Users/xxxx/Downloads/bsddb3-6.2.9-cp39-cp39-win_amd64.whl certifi==2020.12.5 cffi==1.14.4 chardet==4.0.0 chembl-webresource-client==0.10.7 click==7.1.2 colorama==0.4.4 cycler==0.10.0 DateTime==4.3 decorator==4.4.2 Django==3.1.6 easydict==1.9 et-xmlfile==1.1.0 Flask==1.1.2 Flask-Login==0.5.0 Flask-SQLAlchemy==2.4.4 freetype-py==2.2.0 future==0.18.2 idna==2.10 ipython==7.20.0 ipython-genutils==0.2.0 isort==5.7.0 itsdangerous==2.0.1 jedi==0.18.0 Jinja2==2.11.3 joblib==1.0.0 kiwisolver==1.3.1 lazy-object-proxy==1.4.3 lazypredict==0.2.7 llvmlite==0.36.0 lxml==4.6.2 MarkupSafe==1.1.1 matplotlib==3.3.4 mccabe==0.6.1 multitasking==0.0.9 numba==0.53.1 numpy==1.19.5 opencv-python==4.5.2.52 openpyxl==3.0.7 pandas==1.2.1 parso==0.8.1 patsy==0.5.1 pefile==2021.5.24 pickleshare==0.7.5 Pillow==8.1.0 prompt-toolkit==3.0.16 py4j==0.10.9 pycparser==2.20 Pygments==2.8.0 pyinstaller==4.4 pyinstaller-hooks-contrib==2021.2 pylint==2.6.0 pylint-flask==0.6 pylint-flask-sqlalchemy==0.2.0 pylint-plugin-utils==0.6 pyparsing==2.4.7 pyspark==3.1.2 python-dateutil==2.8.1 pytz==2020.5 pywin32-ctypes==0.2.0 PyYAML==5.4.1 requests==2.25.1 requests-cache==0.7.5 rpy2==3.4.2 scikit-learn==0.24.1 scipy==1.6.0 seaborn==0.11.1 six==1.15.0 SQLAlchemy==1.3.23 sqlparse==0.4.1 statsmodels==0.12.2 threadpoolctl==2.1.0 toml==0.10.2 torch==1.7.1 torchvision==0.2.2.post3 tqdm==4.56.2 traitlets==5.0.5 typing-extensions==3.7.4.3 tzlocal==2.1 url-normalize==1.4.3 urllib3==1.26.3 vispy==0.6.6 wcwidth==0.2.5 Werkzeug==1.0.1 wrapt==1.12.1 xlrd==2.0.1 XlsxWriter==1.3.7 yfinance==0.1.55 zope.interface==5.2.0

Edit: I managed to install xgboost, and lightgbm, but now I am getting this error: "Traceback (most recent call last): File "D:/Bioinformatics/Python/Python_for_Bioinformatics_04.py", line 8, in from lazypredict.Supervised import LazyRegressor File "C:\Users\xxxx\AppData\Local\Programs\Python\Python39\lib\site-packages\lazypredict\Supervised.py", line 38, in sklearn.ensemble.gradient_boosting.GradientBoostingClassifier), AttributeError: module 'sklearn.ensemble' has no attribute 'gradient_boosting'"

From your Supervised.py file: "removed_classifiers = [('ClassifierChain', sklearn.multioutput.ClassifierChain), ('ComplementNB', sklearn.naive_bayes.ComplementNB), ('GradientBoostingClassifier', sklearn.ensemble.gradient_boosting.GradientBoostingClassifier),"

So how can I fix this?

Bottom-line, your program has been one colossal waste of my time, why can't you idiots learn how to write robust code?

jam-one avatar Oct 04 '21 15:10 jam-one

A bit late to the party, but managed to fix the exact same problem you had @jam-one.

Inside Supervisor.py, I changed sklearn.ensemble.gradient_boosting.GradientBoostingClassifier to sklearn.ensemble.GradientBoostingClassifier. Be advised there will be like 10 more similar adjustments to do for different imported classes.

At the very end, after the issue with classes has been resolved, there was another error:

Traceback (most recent call last): File "", line 1, in File "D:\xxx\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "C:\Users\xxx\site-packages\lazypredict\Supervised.py", line 73, in REGRESSORS.pop(REGRESSORS.index(i)) ValueError: ('_SigmoidCalibration', <class 'sklearn.calibration._SigmoidCalibration'>) is not in list

That one I resolved by changing failing .pop( ) lines as below (the same was needed for CLASSIFIERS):

for i in removed_regressors:
   if i in REGRESSORS:
      REGRESSORS.pop(REGRESSORS.index(i))

After that it worked fine.

PiotMik avatar Dec 19 '21 22:12 PiotMik

I faced a similar issue with Lazypredict but what @PiotMik suggested solved the issue nicely. After making all the necessary adjustments it will work. In case, you guys are stuck on how to edit Supervised.py, I already had Notepad++ with me so it was easy editing. Once edited it will work fine. I think this issue should be closed now.

nina96 avatar Mar 05 '22 23:03 nina96

@asad-mahmood

As per your suggestion, i have done this but i got the following error :

AttributeError: module 'sklearn.utils' has no attribute '_mocking'

Please guide.

DesolateTraveller avatar Mar 16 '22 12:03 DesolateTraveller

@avijit2403 could you please tell me in which line that error is being shown I would love to help but my Supervised.py doesn't have any such thing and I couldn't find it in sklearn.utils documentation as well. Could you upload ss, I will try to help you if you like.

nina96 avatar Mar 16 '22 15:03 nina96

@nina96

I have updates the supervised.py by the following ways :

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

and found the error in the following

image

DesolateTraveller avatar Mar 18 '22 04:03 DesolateTraveller

@avijit2403 yaar I don't have that checking classifier in my removed_classifiers. Try removing that line of code. My removed_classifiers is starting from the classifier chain. I was also not able to find any such thing in sklearn Screenshot 2022-03-19 125212

nina96 avatar Mar 19 '22 07:03 nina96

I think @nina96's suggestion is working fine...Thanks........ @avijit2403 maybe try to remove all the error lines in Supervised.py, then the calculation performing smoothly. Also @brendalf's also right there is an issue on the new version of sci-kit-learn with lazypredict.

Gurudeeban-Selvaraj avatar Jul 07 '22 20:07 Gurudeeban-Selvaraj

Any updates on this?

gaviral avatar Mar 19 '24 22:03 gaviral

i have the same problem any update

0xnrous avatar Apr 09 '24 13:04 0xnrous