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

Question:

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.

Asked By: Dai

||

Answers:

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.

Answered By: ey893

You could use pipwin to install the appropriate build for your operating system and specific Python version:

Steps:

  1. Uninstall current version of sklearn:

    pip uninstall scikit-learn -y

  2. Install pipwin:

    pip install pipwin

  3. Install sklearn using pipwin:

    pipwin install scikit-learn

Answered By: Jay