【发布时间】:2019-01-06 23:21:51
【问题描述】:
我想使用 MICE、KNN 和 Soft Impute 对来自 fancyimpute 包的插补值进行比较,但是,当我运行我的代码时,与更合理的插补值相比,KNN 和 SoftImpute 只为我的值插补了 0由 MICE 提供。
imputed_numerical=train[['Age']].select_dtypes(include='number']).as_matrix()
Age_MICE=MICE().complete(imputed_numerical)
Age_KNN=KNN(k=3).complete(imputed_numerical)
Age_SoftImpute=SoftImpute().complete(imputed_numerical)
我将结果放入如下所示的数据框中:
Not_Imputed MICE KNN SoftImpute
22.0 [22.0] [22.0] [22.0]
38.0 [38.0] [38.0] [38.0]
26.0 [26.0] [26.0] [26.0]
35.0 [35.0] [35.0] [35.0]
35.0 [35.0] [35.0] [35.0]
NaN [29] [0.0] [0.0]
54.0 [54.0] [54.0] [54.0]
2.0 [2.0] [2.0] [2.0]
27.0 [27.0] [27.0] [27.0]
14.0 [14.0] [14.0] [14.0]
4.0 [4.0] [4.0] [4.0]
58.0 [58.0] [58.0] [58.0]
20.0 [20.0] [20.0] [20.0]
39.0 [39.0] [39.0] [39.0]
14.0 [14.0] [14.0] [14.0]
55.0 [55.0] [55.0] [55.0]
2.0 [2.0] [2.0] [2.0]
NaN [27.6] [0.0] [0.0]
31.0 [31.0] [31.0] [31.0]
NaN [30] [0.0] [0.0]
问题:为什么 KNN 和 SoftImpute 只将 0 归为完成值?
【问题讨论】:
-
这些功能是你手动实现的吗?我在 Python 中找不到任何库。
-
pip install fancyimpute 应该可以工作
标签: python pandas fancyimpute