ecpolley / SuperLearner

Current version of the SuperLearner R package
272 stars 72 forks source link

SL.library: using screening and tuning methods at the same time #134

Closed thaiswalter10 closed 3 years ago

thaiswalter10 commented 3 years ago

Using screening methods and a create.Learner method at the same time returns an error message.

create.Learner method alone woks: data(Boston, package = "MASS") enet = create.Learner("SL.glmnet", detailed_names = T, tune = list(alpha = seq(0, 1, length.out = 5))) sl_lib = c("SL.mean", "SL.lm", enet$names) enet_sl = SuperLearner(Y = Boston$medv, X = Boston[, -14], SL.library = sl_lib)

create.Learner method with screening method launches an error message: sl_lib2 = list("SL.mean", c("SL.lm", "All", "screen.corP"), enet$names) enet_sl2 = SuperLearner(Y = Boston$medv, X = Boston[, -14], SL.library = sl_lib)

Error message: "Error in terms.formula(object) : '.' dans la formule et pas d'argument 'data' More over, Warning message: In FUN(X[[i]], ...) : replacing failed screening algorithm, SL.glmnet_0.75 , with All() in full data '.' dans la formule et pas d'argument 'data' means '.' in the formula and no argument "data"

Defining the library with a list also launches an error message: sl_lib3 = list("SL.mean", "SL.lm", enet$names) enet_sl3 = SuperLearner(Y = Boston$medv, X = Boston[, -14], SL.library = sl_lib)

Thank you very much,

ck37 commented 3 years ago

Hello,

When adding a vector of learners to a list(), you'll want to use c() to append to the list. I also recommend displaying your library so that you can confirm it looks like you expect:

# Use parentheses around an assignment to easily see the result:
(sl_lib2 = list("SL.mean", c("SL.lm", "All", "screen.corP"), enet$names))
# Fixed by combining the vector onto the list with c():
(sl_lib2 = c(list("SL.mean", c("SL.lm", "All", "screen.corP")), enet$names))

Cheers, Chris

thaiswalter10 commented 3 years ago

Thanks !