This learner uses rpart from the rpart package to fit recursive partitioning and regression trees.

Format

An R6Class object inheriting from Lrnr_base.

Value

A learner object inheriting from Lrnr_base with methods for training and prediction. For a full list of learner functionality, see the complete documentation of Lrnr_base.

Parameters

  • factor_binary_outcome = TRUE: Logical indicating whether a binary outcome should be defined as a factor instead of a numeric. This only needs to be modified to FALSE when the user has a binary outcome and they would like to use the mean squared error (MSE) as the splitting metric.

  • ...: Other parameters to be passed directly to rpart (see its documentation for details), and additional arguments defined in Lrnr_base, such as formula.

Examples

data(cpp_imputed)
covs <- c("apgar1", "apgar5", "parity", "gagebrth", "mage", "meducyrs")
task <- sl3_Task$new(cpp_imputed, covariates = covs, outcome = "haz")
rpart_lrnr <- Lrnr_rpart$new()
set.seed(693)
rpart_fit <- rpart_lrnr$train(task)