Scikits机器学习中的价值缺失 [英] Missing values in scikits machine learning
问题描述
scikit-learn中是否可能缺少值?应该如何代表他们?我找不到关于此的任何文档.
Is it possible to have missing values in scikit-learn ? How should they be represented? I couldn't find any documentation about that.
推荐答案
在scikit-learn中根本不支持缺少值.以前在邮件列表上已经对此进行了讨论,但是没有尝试实际编写代码来处理它们.
无论做什么,请勿使用NaN编码缺失值,因为许多算法拒绝处理包含NaN的样本.
Whatever you do, don't use NaN to encode missing values, since many of the algorithms refuse to handle samples containing NaNs.
以上答案已经过时;最新版本的scikit-learn具有类 Imputer
可以进行简单的按特征的缺失值估算.您可以向其提供包含NaN的数组,以将其替换为相应特征的均值,中位数或众数.
The above answer is outdated; the latest release of scikit-learn has a class Imputer
that does simple, per-feature missing value imputation. You can feed it arrays containing NaNs to have those replaced by the mean, median or mode of the corresponding feature.
这篇关于Scikits机器学习中的价值缺失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!