20.5 Blend, fit, predict

  • blend_predictions() performs LASSO regularization to combine the outputs from the stack members to come up with one final prediction.
  • Candidates with non-zero coefficients are kept.
tree_frogs_model_st <-
  tree_frogs_data_st %>%
  blend_predictions()
  • There’s an autoplot() function available, to see what’s going on.
  • If you don’t like what you’re seeing, you can try blend_predictions() again, and setting your own penalty argument.

  • Essentially, what you have, is a linear combination of each member’s prediction, to create one final prediction.

  • With this “instruction” on how to combine candidate models, we fit the whole training set
tree_frogs_model_st <-
  tree_frogs_model_st %>%
  fit_members()

  • And predict on testing set
tree_frogs_test <- 
  tree_frogs_test %>%
  bind_cols(predict(tree_frogs_model_st, .))