lnr_nnetlnr_rf_binarylnr_logistic
Value
Every learner function shares the same contract:
called with (data, formula, ...) it fits the underlying model
and returns a prediction closure which is a function of
newdata returning a numeric vector of predictions (predicted
probabilities of the second factor level for binary learners;
predicted densities for density learners; a matrix of class
probabilities for multiclass learners).
Details
The important thing to know about binary learners is that they
need to produce predictions that the outcome is == 1 or TRUE.
Also, for binary outcomes, we should make sure to use the
determine_weights_for_binary_outcomes in our calls to
super_learner() which calculates the estimated probability of the observed
outcome (either 0 or 1) and then applies the negative log loss function
afterwards. This can be done automatically by declaring outcome_type = 'binary'
in calling super_learner()
Examples
super_learner(
data = mtcars,
learners = list(logistic1 = lnr_logistic, logistic2 = lnr_logistic, lnr_rf_binary),
formulas = list(
.default = am ~ .,
logistic2 = am ~ mpg * hp + .
),
outcome_type = "binary"
)
#>
#> Super Learner (nadir_sl_model)
#> outcome: am (binary)
#> observations: 32 CV folds: 5
#> ensemble weights:
#> logistic1 0.671
#> rf_binary 0.329
#> logistic2 0.000
#> captured conditions (see $errors_from_*, $warnings_from_*):
#> [warning] logistic1 @ cv-training: glm.fit: fitted probabilities numerically 0 or 1 occurred (x5)
#> [warning] logistic2 @ cv-training: glm.fit: fitted probabilities numerically 0 or 1 occurred (x5)
#> [warning] logistic1 @ full-data fit: glm.fit: algorithm did not converge
#> [warning] logistic1 @ full-data fit: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> ... and 2 more unique conditions not shown
#>
#> Methods: predict(x, newdata), plot(x), summary(x), coef(x), fitted(x), ...
