This learner provides fitting procedures for random forest models, using the randomForest package, using randomForest function.

Format

R6Class object.

Value

Learner object with methods for training and prediction. See Lrnr_base for documentation on learners.

Parameters

  • ntree = 500: Number of trees to grow. This should not be set to too small a number, to ensure that every input row gets predicted at least a few times.

  • keep.forest = TRUE: If TRUE, forest is stored, which is required for prediction.

  • nodesize = 5: Minimum number of observations in a terminal node.

  • ...: Other parameters passed to randomForest.

Examples

data(cpp_imputed)
# create task for prediction
cpp_task <- sl3_Task$new(
  data = cpp_imputed,
  covariates = c("bmi", "parity", "mage", "sexn"),
  outcome = "haz"
)
# initialization, training, and prediction with the defaults
rf_lrnr <- Lrnr_randomForest$new()
rf_fit <- rf_lrnr$train(cpp_task)
rf_preds <- rf_fit$predict()