This learner predicts a binary outcome with a known probability, provided by the user as input.

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

  • prob: The probability of the binary outcome. When not provided, this defaults to the mean proportion of observed ones.

Examples

library(sl3)
data(cpp_imputed)
covs <- c("apgar1", "apgar5", "parity", "gagebrth", "mage", "meducyrs")
task <- sl3_Task$new(cpp_imputed, covariates = covs, outcome = "smoked")

# known probability, as in an RCT
lrnr_rct <- Lrnr_prob_known$new(0.5)
rct_fit <- lrnr_rct$train(task)
rct_preds <- rct_fit$predict()