小编Ell*_*ott的帖子

如何消除"外部函数调用(arg 7)中的NA/NaN/Inf"运行使用randomForest进行预测

我在没有找到解决方案的情况下进行了广泛的研究.我已经清理了我的数据集如下:

library("raster")
impute.mean <- function(x) replace(x, is.na(x) | is.nan(x) | is.infinite(x) , 
mean(x, na.rm = TRUE))
losses <- apply(losses, 2, impute.mean)
colSums(is.na(losses))
isinf <- function(x) (NA <- is.infinite(x))
infout <- apply(losses, 2, is.infinite)
colSums(infout)
isnan <- function(x) (NA <- is.nan(x))
nanout <- apply(losses, 2, is.nan)
colSums(nanout)
Run Code Online (Sandbox Code Playgroud)

问题出现了运行预测算法:

options(warn=2)
p  <-   predict(default.rf, losses, type="prob", inf.rm = TRUE, na.rm=TRUE, nan.rm=TRUE)
Run Code Online (Sandbox Code Playgroud)

所有的研究都表明它应该是数据中的NA或Inf或NaN,但我没有发现任何数据.我正在制作数据和randomForest摘要可用于[删除] Traceback的调查并没有显示太多(对我来说):

4: .C("classForest", mdim = as.integer(mdim), ntest = as.integer(ntest), 
       nclass = as.integer(object$forest$nclass), maxcat = as.integer(maxcat), 
       nrnodes = as.integer(nrnodes), jbt = as.integer(ntree), …
Run Code Online (Sandbox Code Playgroud)

runtime-error r predict random-forest

14
推荐指数
2
解决办法
6万
查看次数

标签 统计

predict ×1

r ×1

random-forest ×1

runtime-error ×1