当我在构建四种算法的集成模型之后,在下面的代码中运行预测函数,然后尝试使用该集成模型对新数据进行预测时,出现以下错误:未找到对象“ nn” >
models2 <- caretList(
log_sales~., data=train.data.final,
trControl=trnCtrl, tuneList=list(
rf=caretModelSpec(method="rf", tuneGrid=expand.grid(.mtry=c(1:8)) ),
nn=caretModelSpec(method="nnet", tuneGrid=expand.grid(.decay =
c(0,0.001,0.01, 0.1, 0.5), .size = c(5:10)), preProcess=c("center",
"scale"),linout=TRUE, trace=FALSE, maxit = 1000),
gbm=caretModelSpec(method="gbm",
tuneGrid=expand.grid(interaction.depth = seq(1, 7, by = 2), n.trees =
seq(100, 1000, by = 50),shrinkage = c(0.01,0.1), n.minobsinnode = 10)
),
xgb=caretModelSpec(method="xgbTree", tuneGrid=expand.grid(nrounds =
1000,eta = c(0.01,0.05, 0.07, 0.1), max_depth = c(4:14), gamma=0,
colsample_bytree = c(0.75), subsample = c(0.50), min_child_weight =0 ) )
)
)
stack.glm <- caretStack(models2, method="glm", trControl=trnCtrl)
stack.pred <- predict(stack.glm, newdata = testing)
eval(predvars,data,env)中的错误:找不到对象'nn'