简体   繁体   中英

MICE implementation in python

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.

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

This error usually happens when you deal with None values. Have you tried:

df_train.fillna(value=np.nan, inplace=True)

instead?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM