iskandr/fancyimpute

No module named 'sklearn.impute._iterative'; 'sklearn.impute' is not a package

soliverc opened this issue · 2 comments

Just tried the first line of the tutorial on the main github page:

from fancyimpute import KNN, NuclearNormMinimization, SoftImpute, BiScaler

# Use 3 nearest rows which have a feature to fill in each row's missing features
X_filled_knn = KNN(k=3).fit_transform(data)

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-154-a5343255137c> in <module>
      1 # X is the complete data matrix
      2 # X_incomplete has the same values as X except a subset have been replace with NaN
----> 3 from fancyimpute import KNN, NuclearNormMinimization, SoftImpute, BiScaler
      4 
      5 # Use 3 nearest rows which have a feature to fill in each row's missing features

~\AppData\Roaming\Python\Python37\site-packages\fancyimpute\__init__.py in <module>
     12 
     13 # while iterative imputer is experimental in sklearn, we need this
---> 14 from sklearn.experimental import enable_iterative_imputer
     15 from sklearn.impute import IterativeImputer
     16 

~\Anaconda3\lib\site-packages\sklearn\experimental\enable_iterative_imputer.py in <module>
     13 """
     14 
---> 15 from ..impute._iterative import IterativeImputer
     16 from .. import impute
     17 

ModuleNotFoundError: No module named 'sklearn.impute._iterative'; 'sklearn.impute' is not a package

How can I fix this?

Looks like a scikit-learn problem. You need sklearn version at least scikit-learn>=0.21.2.

Hi, @soliverc. It seems that the current stable version of scikit-learn module has included the impute submodule, as you can see here :)
https://scikit-learn.org/stable/modules/classes.html?highlight=impute#module-sklearn.impute

You can update your local sklearn module via:
pip install --upgrade scikit-learn