MICE implementation in python

krishna picture krishna · Jun 3, 2018 · Viewed 15.9k times · Source

I am trying to use MICE implementation using the following link:

Missing value imputation in python using KNN

from fancyimpute import MICE as MICE
df_complete=MICE().complete(df_train)

I am getting following error:

ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

On the link also, it says that they have replaced with NaN. I am not sure what does it mean? I have already tried: df_train.isnull(np.array([np.nan, 0], dtype=float)) but it is not helping either.

Answer

krishna picture krishna · Jun 4, 2018
df_train_numeric = df_train[['Age']].select_dtypes(include=[np.float]).as_matrix()
df_complete=MICE().complete(df_train_numeric)

Thanks to Data imputation with fancyimpute and pandas