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

h2o.stackedEnsemble have already have the parameter metalearner_nfolds, but we can't access the cross-validition prediction result. #16459

Open
Yijuan-w opened this issue Dec 12, 2024 · 2 comments
Assignees
Labels

Comments

@Yijuan-w
Copy link

ensemble_2 <- h2o.stackedEnsemble(x = predictors, y = response, training_frame = data_h2o,
                                base_models = list(xgb_model,dl_model, rf_model,glm_model, nb_model),
                                metalearner_algorithm = "glm",
                                metalearner_nfolds = 5,  
                                seed = 1)

it works well, but when I want to plot ROC curve to compare the base model and ensemble model, I can't get the prediction result.
it should also have the parameter keep_cross_validation_predictions
please! Many many thanks!

@tomasfryda tomasfryda self-assigned this Jan 7, 2025
@tomasfryda
Copy link
Contributor

@Yijuan-w you can get cross-validation ROC curve from the metalearner like this:

perf <- h2o.performance(ensemble, xval = TRUE)
plot(perf, type="roc")

it should also have the parameter keep_cross_validation_predictions

You can do it by using metalearner_params:

ensemble <- h2o.stackedEnsemble(y = response, training_frame = df,
                                  base_models = models,
                                  metalearner_algorithm = "glm",
                                  metalearner_nfolds = 5,
                                  metalearner_params = list(
                                    keep_cross_validation_predictions = TRUE
                                  ), 
                                  seed = 1)

metalearner <- ensemble@model$metalearner_model
fold_id <- 1
cv_preds <- h2o.getFrame(metalearner@model$cross_validation_predictions[[fold_id]]$name)
cv_preds

@Yijuan-w
Copy link
Author

Yijuan-w commented Jan 8, 2025

wooo
Thank your so much!

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

No branches or pull requests

2 participants