This learner applies a univariate outcome learner across a vector of outcome variables, effectively transforming it into a multivariate outcome learner

Format

R6Class object.

Value

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

Parameters

learner

The learner to wrap.

Common Parameters

Individual learners have their own sets of parameters. Below is a list of shared parameters, implemented by Lrnr_base, and shared by all learners.

covariates

A character vector of covariates. The learner will use this to subset the covariates for any specified task

outcome_type

A variable_type object used to control the outcome_type used by the learner. Overrides the task outcome_type if specified

...

All other parameters should be handled by the invidual learner classes. See the documentation for the learner class you're instantiating

Examples

library(data.table)

# simulate data
set.seed(123)
n <- 1000
p <- 5
pY <- 3
W <- matrix(rnorm(n * p), nrow = n)
colnames(W) <- sprintf("W%d", seq_len(p))
Y <- matrix(rnorm(n * pY, 0, 0.2) + W[, 1], nrow = n)
colnames(Y) <- sprintf("Y%d", seq_len(pY))
data <- data.table(W, Y)
covariates <- grep("W", names(data), value = TRUE)
outcomes <- grep("Y", names(data), value = TRUE)

# make sl3 task
task <- sl3_Task$new(data.table::copy(data),
  covariates = covariates,
  outcome = outcomes
)

# train multivariate learner and make predictions
mv_learner <- make_learner(Lrnr_multivariate, make_learner(Lrnr_glm_fast))
mv_fit <- mv_learner$train(task)
mv_pred <- mv_fit$predict(task)
mv_pred <- unpack_predictions(mv_pred)