lazypredict.Supervised.LazyClassifier. ImportError: Cannot import name '_raise_dep_warning_if_not_pytest' from 'sklearn.utils.deprecation'

Viewed 7658

I tried:

from lazypredict.Supervised import LazyClassifier

But got the following traceback:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-f518cae57501> in <module>
     10 from sklearn.linear_model import LogisticRegression
     11 from sklearn.ensemble import RandomForestClassifier
---> 12 from lazypredict.Supervised import LazyClassifier
     13 from sklearn.model_selection import GridSearchCV
     14 from sklearn.metrics import accuracy_score

~\AppData\Roaming\Python\Python38\site-packages\lazypredict\Supervised.py in <module>
     14 from sklearn.preprocessing import StandardScaler, OneHotEncoder, OrdinalEncoder
     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

S:\anaconda\lib\site-packages\sklearn\utils\testing.py in <module>
      5 from . import _testing  # type: ignore
      6 from ..externals._pep562 import Pep562
----> 7 from ..utils.deprecation import _raise_dep_warning_if_not_pytest
      8 
      9 deprecated_path = 'sklearn.utils.testing'

ImportError: cannot import name '_raise_dep_warning_if_not_pytest' from 'sklearn.utils.deprecation' (S:\anaconda\lib\site-packages\sklearn\utils\deprecation.py)

I was working in a Jupyter notebook, and have already tried upgrading scikit-learn too.

3 Answers

This is most likely caused by incompatible versions of lazypredict and scikit-learn. Per the current LazyPredict requirements file, it needs scikit-learn==0.23.1.

This should be fixed with:

pip uninstall scikit-learn -y
pip install scikit-learn==0.23.1

In case it helps someone else, the above solution to install scikit-learn version 0.23.1 didn't work for me. I'm using Anaconda and did conda update --all and then ran conda install scikit-learn-intelex and the import worked for me afterwards.

my error was resolved by doing this:

!pip uninstall scikit-learn -y
!pip install scikit-learn==0.24
Related