使用 horzion=1 对 Lasso 和 Elastic Net 进行运行时间序列交叉验证时出现问题

Problem running time series cross validation with horzion=1 for Lasso and Elastic Net

提问人:Big Teo 提问时间:8/25/2023 更新时间:8/25/2023 访问量:15

问:

我正在尝试使用 R 插入符号的训练函数对 Lasso 和 Elastic Net 进行超参数调整。我希望 horizon=1 仅使用一个验证数据点来验证每个折叠。

myTimeControl <- trainControl(method = "timeslice",
                                  initialWindow = 20,
                                  horizon = 1,
                                  savePredictions = "final",
                                  fixedWindow = FALSE,
                                  allowParallel = TRUE)
# Lasso
fraction <- seq(0, 1, by = 0.1)
lassoGrid <-  expand.grid(fraction=fraction)
lasso <- caret::train(y1 ~ ., data = df_lagged,
                              trControl = myTimeControl, metric = 'RMSE',
                              method = 'lasso', tuneGrid = lassoGrid,
                              preProcess = c("center", "scale"))
 
# Elastic Net
enetGrid <-  expand.grid(fraction=fraction,
                                 lambda=c(0.01, 0.025, 0.05, 0.1, 0.2, 0.5))
 enet <- caret::train(y1 ~ ., data = df_lagged,
                             trControl = myTimeControl, metric = 'RMSE',
                             method = 'enet', tuneGrid = enetGrid,
                             preProcess = c("center", "scale"))

但是,我无法这样做,而是收到以下警告:

Error in { : 
  task 1 failed - "arguments imply differing number of rows: 11, 2"

当地平线大于 1 时,我没有收到此错误。

关于为什么会发生这种情况的任何建议?提前致谢!

仅当 horizon=1 时才会出现此问题。horizon 的所有其他值都很好用。

交叉验证 R-CALET

评论


答: 暂无答案