python中的MICE实现

2024-09-23 08:15:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用以下链接使用MICE实现:

Missing value imputation in python using KNN

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

我得到以下错误:

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''

在链接上,它还说,他们已经取代了南。我不知道这是什么意思?我已经试过了:df_train.isnull(np.array([np.nan, 0], dtype=float)),但也没用。


Tags: thetoindfvalue链接npnot
2条回答

此错误通常在处理None值时发生。你试过了吗:

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

相反呢?

df_train_numeric = df_train[['Age']].select_dtypes(include=[np.float]).as_matrix()
df_complete=MICE().complete(df_train_numeric)

感谢Data imputation with fancyimpute and pandas

相关问题 更多 >