This learner adds interactions to its chained task. Intended for use in a Pipeline, defining a coupling of the interactions with the learner.

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

  • interactions: A list whose elements are a character vector of covariates from which to create interaction terms.

  • warn_on_existing: If TRUE, produce a warning if there is already a column with a name matching this given interaction term.

Examples

data(cpp_imputed)
covars <- c("apgar1", "apgar5", "parity", "gagebrth", "mage", "meducyrs", "sexn")
outcome <- "haz"
task <- sl3_Task$new(cpp_imputed, covariates = covars, outcome = outcome)
interactions <- list(c("apgar1", "parity"), c("apgar5", "parity"))
lrnr_interact <- Lrnr_define_interactions$new(
  list(c("apgar1", "parity"), c("apgar5", "parity"))
)
lrnr_glm <- Lrnr_glm$new()
interaction_pipeline_glm <- make_learner(Pipeline, lrnr_interact, lrnr_glm)
fit <- interaction_pipeline_glm$train(task)