This function extracts cross-validated accuracy values from a list of trained machine learning models, summarizes their median and standard deviation, and optionally plots a bar chart or selects base models for stacking.
Arguments
- models
A named list of trained ML models, each with a
resample
element containing cross-validated accuracy.- file_name
(Optional) Character string specifying the filename prefix for the saved accuracy plot (PDF format).
- base_models
Logical. If
TRUE
, the function selects and returns base models usingchoose_base_models()
for stacking.- return
Logical. If
TRUE
, the function saves a barplot of the model accuracy values in theResults/
directory.
Value
A list containing:
Accuracy
: A data frame with the median and standard deviation of accuracy for each model.Top_model
: A character string naming the model with the highest median accuracy.Base_models
(optional): A character vector of selected base models ifbase_models = TRUE
.
Details
This function assumes that each model in the list has a $resample
component containing
a column named Accuracy
. It calculates the median and standard deviation of accuracy
for each model and creates a barplot (if return = TRUE
) with error bars.
If base_models = TRUE
, it calls a helper function choose_base_models()
to select
models for use in stacking.