3

I am just trying to use the MICE function from fancyimpute. Simple line of code from fancyimpute import MICE gives an error cannot import name 'MICE'

I did try to consult https://github.com/iskandr/fancyimpute (i find it strange that MICE is nowhere to be found there but then people are implementing it https://medium.com/logicai/5-useful-python-packages-from-kaggles-kernels-you-didn-t-know-existed-part-2-4b35ba2d812) as well as similiar problems on stack concerning MICE and importing problems but without of luck

Noah Weber
  • 312
  • 2
  • 13
  • 1
    IterativeImputer() should be the alternative, but it still baffles me how did others manage to implement it since it seems MICE does not exist in fancyimpute... – Noah Weber Jan 10 '19 at 19:51
  • @joel I just used IterativeImputer() in the end. Which worked well. – Jonathan Bone Sep 26 '19 at 15:37

2 Answers2

4

The below steps worked for me on MAC OSX.

  1. Use easy_install fancyimpute in your terminal instead of pip install fancyimpute

Unable to install fancyimpute for use in Jupyter

  1. Use 'from fancyimpute import IterativeImputer as MICE' in your jupyter notebook. Looks like MICE is now called IterativeImputer.

https://github.com/iskandr/fancyimpute/issues/81

  1. Use 'df1 = MICE().fit_transform(df)' on your dataframe. Looks like IterativeImputer does not have the function/method 'complete' anymore and the fit or fit_transform should be used with it instead.
ARV
  • 41
  • 2
3
from fancyimpute import IterativeImputer as MICE

MICE().fit_transform(df)
mel1
  • 73
  • 7