Search code examples
pythonscikit-learnimporterror

ImportError: cannot import name 'HalvingGridSearchCV' from 'sklearn.model_selection'


I am running scikit-learn 0.24.2 on the intelpython3_full conda distribution. I am trying to run:

from sklearn.model_selection import HalvingGridSearchCV

and get the following error:

ImportError: cannot import name 'HalvingGridSearchCV' from 'sklearn.model_selection'

I am trying to run it from jupyter notebook.

Already tried reinstalling scikit-learn:

conda uninstall scikit-learn
conda install scikit-learn -c intel 

Also tried:

-c conda-forge

Always get this error. Other imports with sklearn, for instance GridSearchCV work. Can someone help me with this?


Solution

  • This must be run first:

    from sklearn.experimental import enable_halving_search_cv 
    

    and then this:

    from sklearn.model_selection import HalvingGridSearchCV