【发布时间】:2022-01-04 01:17:58
【问题描述】:
我正在使用 RandomForestSRC 来创建使用回归的随机森林模型,并且我想对最优 mtry、nodesize、ntrees、nodedepth 组合执行网格搜索,以便更好地可视化优化过程。
我尝试了以下方法:
mtry <- c(4,8,16)
nodesize <- c(50,150,300)
ntrees <- c(500,1000,2000)
nodedepth <- c(5,10)
frmodel <- rfsrc(mort_30 ~ variable1+variable2+variable3, #(ect)
data= data.train, mtry= mtry, nodesize= nodesize, ntrees=ntrees,
nodedepth=nodedepth, blocksize=1, importance=TRUE, seed=40)
但我不断收到此错误:
I if (mtry < 1 | mtry >n.xvar) mtry <- max(1, min(mtry, n.xvar)):
the condition has length > 1 and only the first element will be used
似乎我无法为这些分配多个值。除了为每个组合手动制作一棵树之外,还有其他方法吗?
【问题讨论】:
标签: r random-forest grid-search