我正在尝试在大型数据集(5000x300)上运行randomForest.不幸的是,我收到如下错误消息:
I'm trying to run a randomForest on a large-ish data set (5000x300). Unfortunately I'm getting an error message as follows:
> RF <- randomForest(prePrior1, postPrior1[,6] + ,,do.trace=TRUE,importance=TRUE,ntree=100,,forest=TRUE) Error in randomForest.default(prePrior1, postPrior1[, 6], , do.trace = TRUE, : NA/NaN/Inf in foreign function call (arg 1)所以我尝试使用以下方法找到任何不适用的内容:
So I try to find any NA's using :
> df2 <- prePrior1[is.na(prePrior1)] > df2 character(0) > df2 <- postPrior1[is.na(postPrior1[,6])] > df2 numeric(0)这使我相信是Inf造成了问题,因为似乎没有任何NA.
which leads me to believe that it's Inf's that are the problem as there don't seem to be any NA's.
关于如何根除Inf的任何建议?
Any suggestions for how to root out Inf's?
推荐答案您可能正在寻找is.finite,尽管我不能100%地确定问题是输入数据中的Infs.
You're probably looking for is.finite, though I'm not 100% certain that the problem is Infs in your input data.
请务必仔细阅读is.finite的帮助,以了解它会找出哪些缺失,无穷等组合.具体来说,这是
Be sure to read the help for is.finite carefully about which combinations of missing, infinite, etc. it picks out. Specifically, this:
> is.finite(c(1,NA,-Inf,NaN)) [1] TRUE FALSE FALSE FALSE > is.infinite(c(1,NA,-Inf,NaN)) [1] FALSE FALSE TRUE FALSE其中之一与其他事物不同.毫不奇怪,还有一个is.nan函数.
One of these things is not like the others. Not surprisingly, there's an is.nan function as well.
更多推荐
R是否有找到Inf/
发布评论