Description Usage Arguments Value Examples
This function needs a workflows::workflow ready for tune::fit_resamples. It does different fold cross-validation to vary the training set sizes and then collects the predictions and scores them.
1 2 3 4 5 6 7 8 9 10 | learn_curve_cv(
data,
wf,
folds,
repeats,
metric_calculator,
strata = NULL,
pkgs = c("mirmodels"),
n_cores = 1
)
|
data |
A data frame. The data to be used for the modelling. |
wf |
A |
folds |
An integer vector. Different |
repeats |
The number of times to repeat each cross-validation. |
metric_calculator |
A function which takes a single data frame argument
and returns a double. The data frame that will be passed to this function
is the output of |
strata |
A string. Variable to stratify on when splitting for cross-validation. |
pkgs |
A character vector. Passed to |
n_cores |
A positive integer. The cross-validation can optionally be done in parallel. Specify the number of cores for parallel processing here. |
A tibble with 2 columns:
training_samples
: The number of samples used in training.
score
: The score computed by metric_calculator()
.
1 2 3 4 5 6 7 8 9 10 11 | data("BostonHousing", package = "mlbench")
bh <- dplyr::select_if(BostonHousing, is.numeric)
mod <- parsnip::linear_reg(penalty = 0, mixture = 0) %>%
parsnip::set_engine("lm")
wf <- workflows::workflow() %>%
workflows::add_formula(medv ~ .) %>%
workflows::add_model(mod)
metric_calculator <- ~ yardstick::mae(., medv, .pred)$.estimate
lccv <- suppressWarnings(
learn_curve_cv(bh, wf, 2:9, 3, metric_calculator, n_cores = 4)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.