This function plots the confusion matrix from a tuned xgboost model.
Examples
set.seed(12)
mtcars$cluster <- as.character(mtcars$am)
folds <- rsample::vfold_cv(mtcars, v = 2)
rec <- recipes::recipe(cluster ~ ., data = mtcars)
mod <- parsnip::logistic_reg()
control <- tune::control_resamples(save_pred = TRUE)
metrics <- yardstick::metric_set(
yardstick::accuracy,
yardstick::bal_accuracy,
yardstick::f_meas,
yardstick::roc_auc
)
res <- tune::fit_resamples(mod, rec, folds, control = control, metrics = metrics)
metric_df <- tune::collect_metrics(res)
metric_df$.estimate <- metric_df$mean
plotConfMat(res, name = "model", output_dir = tempdir(), metric_df = metric_df)
#> Scale for fill is already present.
#> Adding another scale for fill, which will replace the existing scale.