【发布时间】:2015-11-20 15:48:06
【问题描述】:
我正在使用randomForest 包通过标准过程对二进制结果变量进行分类。我首先必须强制更改所有变量以确保它们是数字,然后使用 na.roughfix 处理缺失值:
data <- read.csv("data.csv")
data <- lapply(data, as.numeric)
data <- na.roughfix(data)
然后我运行模型:
model <- randomForest(as.factor(outcome) ~ V1 + V2...+ VN,
data=data,
importance=TRUE,
ntree=500)
我收到以下错误:
na.fail.default(list(as.factor(outcome) = c(2L, 2L, 1L, : 对象中的缺失值
na.roughfix 插补应该已经解决了这个问题(我之前已经让它工作了,research on here shows that it should work),对吧?有什么建议?
【问题讨论】:
标签: r machine-learning random-forest missing-data