gpt4 book ai didi

r - 插入符号 : RFE with variable tuneGrid

转载 作者:行者123 更新时间:2023-11-30 09:37:56 25 4
gpt4 key购买 nike

我正在尝试使用插入符来拟合 PLS 模型,同时优化组件“ncomps”的数量:

library("caret")
set.seed(342)
train <- as.data.frame ( matrix( rnorm(1e4) , 100, 100 ) )

ctrl <- rfeControl(functions = caretFuncs,
method = "repeatedcv",
number=2,
repeats=1,
verbose =TRUE
)

pls.fit.rfe <- rfe(V1 ~ .,
data = train,
method = "pls",
sizes = 6,
tuneGrid = data.frame(ncomp = 7),
rfeControl = ctrl
)

{ 中的错误: 任务 1 失败 - “无法确定最终调整参数”另外:有 50 个或更多警告(使用 warnings() 查看前 50 个)

组件数量无效,ncomp

将大小设置为 6 可以解决该问题。当 min(sizes) < max(ncomp) 时出现错误是有道理的,但是有没有办法根据 RFE 迭代中使用的特征数量(即 size 变量)来改变 ncomp ?我只是想同时优化各种尺寸和#components。

最佳答案

尝试使用 tuneLength = 7 而不是 tuneGrid。前者更灵活,并且会根据数据集的大小使用适当的 ncomp:

> pls.fit.rfe  pls.fit.rfeRecursive feature selectionOuter resampling method: Cross-Validated (2 fold, repeated 1 times) Resampling performance over subset size: Variables   RMSE Rsquared  RMSESD RsquaredSD Selected         6 1.0229  0.01684 0.04192  0.0155092                 99 0.9764  0.00746 0.01096  0.0008339        *The top 5 variables (out of 99):

如果您不想这样做,您可以随时write your own也有拟合功能。

最大

关于r - 插入符号 : RFE with variable tuneGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27784008/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com