Skip to contents

Two plot types are provided:

type = "comparison" (default)

For each candidate learner and for the weighted super learner ensemble: bars show the mean cross-validated held-out loss, open circles show each fold's held-out loss, and point-ranges show \(\pm 1\) standard deviation across folds. This automates the figure shown in the package README, with the ensemble added as its own row. Learners are ordered best (lowest loss) at top.

type = "fitted"

Cross-validated ensemble predictions on the held-out folds against the observed outcomes, with the identity line for reference. Each prediction comes from learners trained without that observation. Not defined for outcome_type = "density" or "multiclass".

The loss is chosen by outcome_type: mean squared error for continuous outcomes and negative log loss otherwise.

Requires the ggplot2 package (listed in Suggests).

Usage

# S3 method for class 'nadir_sl_model'
plot(x, type = c("comparison", "fitted"), ...)

Arguments

x

An object of class nadir_sl_model as returned by super_learner().

type

One of "comparison" or "fitted".

...

Ignored; included for compatibility with the generic.

Value

A ggplot object, which prints when returned to the console.

Examples

if (requireNamespace("ggplot2", quietly = TRUE)) {
  sl_model <- super_learner(
    data = mtcars,
    formula = mpg ~ cyl + hp,
    learners = list(mean = lnr_mean, lm = lnr_lm)
  )
  plot(sl_model) # learner comparison
  plot(sl_model, type = "fitted") # observed vs. CV ensemble predictions
}