R/examples/example_predict.R

Defines functions predict_fun

# Predict function to act on a single bagged model and a single sampled test data set obtained
# from instance models by applying a transformation function (e.g. means).
predict_fun <- function(model, data) {
  data$y <- NULL
  return(predict(model, newdata = data, type = "response"))
}

# This yields 100 * 100 predictions. It returns a list of lists 
# of predictions. Each prediction (list) contains fields:
# - predictions: output of predict_fun passed to this method
# - idx_of_bagged_model: index of the bagged model (in this case 1-100)
# - idx_of_test_set: index of test set generated by first level model (in this case 1-100)
predict(
  mf_model,
  data_new = data_new,
  predict_fun = predict_fun
)
fortunar/input_uncertainty_model documentation built on May 30, 2019, 6:26 a.m.