Description Usage Arguments Details Value Examples
In general, the function passed to sl_control$weight_fn
should expect a list of
named lists of outcomes (Y), predictions (pred) in validation folds. Typically,
this function is used to maximize sl_control$optim_risk_fn
over
weights. The function should return a named list. One of the names in the list should
be weight
, which is the optimized weights. Other entries in the return list
are passed on to sl_control$cv_risk_fn
(e.g., things needed to compute
cross-validated measure of association, though none are present for this particular
function).
1 | weight_sl_01(input, sl_control)
|
input |
A list where each entry corresponds to a validation fold. Each entry is a list
with entries: Y (univariate outcome for this validation fold), pred (matrix of predictions
from |
sl_control |
Super learner control options. |
In this case, the function selects the single outcome with the lowest value
returned by sl_control$optim_risk_fn
Numeric vector giving 0/1 weights for super learner.
1 2 3 4 5 6 7 8 | #Simulate data and properly format:
input <- list(list(Y = rbinom(50,1,0.5), pred = cbind(rnorm(50), rnorm(50))))
#Linear ensemble
sl_control <- list(ensemble_fn = "ensemble_linear", optim_risk_fn = "optim_risk_sl_auc")
#Get weights to minimize optim_risk:
sl_weight <- weight_sl_01(input, sl_control)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.