pythonscikit-learnimblearn

scikit-learn error although it is properly installed


My code is as follows:

from imblearn import over_sampling

I get this error:

cannot import name 'DistanceMetric' from 'sklearn.metrics'

A simple import on imblearn is giving the same error. I tried reinstalling scikit learn and scipy, but I still get the same error.


Solution

  • Since it is working fine on my computer, it must be your installation. Try uninstalling scikit-learn before reinstalling.

    Edit: If that is not working I would try running: python -m pip show scikit-learn

    uninstall sklearn, delete the directory for sklearn, reboot the computer, and reinstall sklearn.