R是否有找到Inf/

编程入门 行业动态 更新时间:2024-10-28 04:29:14
本文介绍了R是否有找到Inf/-Inf值的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在大型数据集(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/

本文发布于:2023-10-16 11:21:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497412.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Inf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!