【问题标题】:"argument is of length zero" error in RandomForest tuneRF()RandomForest tuneRF() 中的“参数长度为零”错误
【发布时间】:2016-03-15 07:43:08
【问题描述】:

我使用了这个代码,

tuneRF(x = mtry[,c(4:18)],
   y = mtry$Os, ntreeTry=50, stepFactor=2, 
   improve=0.05,trace=TRUE, plot=TRUE, doBest=FALSE)

得到了错误:

if (errorOld 参数长度为零

我应该改变什么?

【问题讨论】:

  • 您应该提供reproducible example
  • 你的数据集叫mtry吗??
  • 是的。我在数据集上准备了它占总数据的 80%。 ans os 是我想预测的一列。

标签: r regression random-forest


【解决方案1】:

当我不小心输入了响应列不存在的列时,我遇到了同样的错误。也许您的 mtry$Os 列不存在(如果没有可重现的示例,很难解决您的问题)。

例子:

> library(randomForest)
> data("iris")
> tuneRF(x = iris[1:4,], y = iris$notacol)
Error in if (errorOld < 0) stop("Initial setting gave 0 error and no room for improvement.") : 
  argument is of length zero

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-01
    • 1970-01-01
    • 2016-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-08
    相关资源
    最近更新 更多