Bootstrap Ensemble Learner with SE Prediction
Source:R/LearnerRegrBootstrapSE.R
mlr_learners_regr.bootstrap_se.RdWraps any regression learner and trains a bootstrap ensemble. Predictions return mean and SE across bootstrap samples.
Creates a new instance of this R6 class.
Arguments
- learner
(mlr3::LearnerRegr)
Base learner to bootstrap.
Details
This learner creates a bootstrap ensemble by:
Taking
n_bootstrapbootstrap samples (sampling with replacement)Training the base learner on each sample, storing the trained state
During prediction, restoring each state and querying its model
Computing mean and SD of predictions across the ensemble
The standard deviation across bootstrap predictions serves as the standard error estimate.
The bootstrap tasks are rebuilt from the task's feature/target data, so task properties beyond that (observation weights, strata, groups) are not forwarded to the ensemble members and the corresponding base-learner properties are not advertised by the wrapper.
The wrapped base learner ($wrapped) remains untrained after training the wrapper.
Use $base_learner() to get a trained clone of the base learner.
Parameters
The base learner's parameters are exposed with the base. prefix
(e.g. base.maxdepth).
Own parameters:
n_bootstrap::integer(1)
Number of bootstrap samples. Initialized to30.
Fields
$wrapped:: mlr3::LearnerRegr
Read-only access to the wrapped base learner.
Examples
if (FALSE) { # \dontrun{
# Wrap ranger with bootstrap SE
learner <- lrn("regr.bootstrap_se", learner = lrn("regr.ranger"))
learner$param_set$set_values(n_bootstrap = 10)
# Train on a task
task <- tsk("mtcars")
learner$train(task)
# Predict with SE
pred <- learner$predict(task)
pred$se # Standard errors
} # }