Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predict function in CaretEnsemble package returns the error: "object nn not found" #246

Open
sfallahpour opened this issue Jul 10, 2019 · 0 comments

Comments

@sfallahpour
Copy link

sfallahpour commented Jul 10, 2019

I tried to create an ensemble model using the “CaretEnsemble” package. I wrote the following code

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)

Which runs totally fine but when I try to use the stacked model to predict new data I get the following error:

pred <- predict(stack.glm, newdata = testing)
Error in eval(predvars, data, env) : object 'nn' not found

When I run “stack.glm$models$nn” I get the results for neural network but I am not sure if object “nn” in the error message refers to same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant