| superlearner | R Documentation |
This function creates a predictor object (class learner) from a list of existing learner objects. When estimating this model a stacked prediction will be created by weighting together the predictions of each of the initial learners The weights are learned using cross-validation.
superlearner(
learners,
data,
nfolds = 10,
meta.learner = metalearner_nnls,
model.score = mse,
mc.cores = NULL,
future.seed = TRUE,
silent = TRUE,
name.prefix = NULL,
...
)
learners |
(list) List of learner objects (i.e. learner_glm) |
data |
(data.frame) Data containing the response variable and covariates. |
nfolds |
(integer) Number of folds to use in cross-validation to estimate the ensemble weights. |
meta.learner |
(function) Algorithm to learn the ensemble weights
(default non-negative least squares). Must be a function of the response
(nx1 vector), |
model.score |
(function) Model scoring method (see learner) |
mc.cores |
(integer) If not NULL, then parallel::mcmapply is used with
|
future.seed |
(logical or integer) Argument passed on to future.apply::future_lapply. If TRUE, then .Random.seed is used if it holds a L'Ecuyer-CMRG RNG seed, otherwise one is created randomly. |
silent |
(logical) Suppress all messages and progressbars |
name.prefix |
(character) Prefix used to name learner objects in
|
... |
Additional arguments to parallel::mclapply or future.apply::future_lapply. |
Luedtke & van der Laan (2016) Super-Learning of an Optimal Dynamic Treatment Rule, The International Journal of Biostatistics.
predict.superlearner weights.superlearner score.superlearner
sim1 <- function(n = 5e2) {
x1 <- rnorm(n, sd = 2)
x2 <- rnorm(n)
y <- x1 + cos(x1) + rnorm(n, sd = 0.5**.5)
data.frame(y, x1, x2)
}
m <- list(
"mean" = learner_glm(y ~ 1),
"glm" = learner_glm(y ~ x1 + x2)
)
sl <- superlearner(m, data = sim1(), nfolds = 2)
predict(sl, newdata = sim1(n = 5))
predict(sl, newdata = sim1(n = 5), all.learners = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.