Can not use MICE from fancyimputer (Python)

Viewed 4852

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

2 Answers

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.
from fancyimpute import IterativeImputer as MICE

MICE().fit_transform(df)
Related