Search code examples
pythonmachine-learningscikit-learnmissing-data

ImportError: cannot import name '_check_weights' from 'sklearn.neighbors._base'


I am trying to do Missforest as a method for handling missing values in table data.

import sklearn
print(sklearn.__version__)
->1.2.1

import sklearn.neighbors._base
import sys
sys.modules['sklearn.neighbors.base'] = sklearn.neighbors._base

!pip install missingpy
from missingpy import MissForest

It was working fine until now, but since yesterday, the following error message has appeared.

ImportError: cannot import name '_check_weights' from 'sklearn.neighbors._base'

I would like to know how to deal with this error.


Solution

  • the same thing happened to me, I changed the versions of the packages. I have the following setting and it works for me: scikit-learn = 1.1.2, scipy = 1.9.1, missingpy = 0.2.0.