Skip to contents

Produces feature importance charts, observed-vs-predicted scatter plots, and cross-validation loss curves from a climasus_ml object returned by sus_mod_ml().

Usage

sus_mod_plot_ml(
  x,
  type = c("importance", "fit", "cv_log"),
  output_type = c("plot", "table", "all"),
  n_top = 20L,
  interactive = FALSE,
  base_size = 12L,
  save_plot = NULL,
  lang = c("pt", "en", "es"),
  verbose = FALSE
)

Arguments

x

A climasus_ml object produced by sus_mod_ml().

type

Character. Plot type: "importance" (default), "fit", or "cv_log".

output_type

Character. "plot" (default), "table", or "all" (named list $plot, $table, $data).

n_top

Integer. Maximum number of features to show in the importance plot. Default 20L.

interactive

Logical. TRUE converts the ggplot2 output to an interactive plotly widget. Default FALSE.

base_size

Numeric. ggplot2 base font size. Default 12.

save_plot

Character or NULL. File path to save the plot.

lang

Character. Language for labels: "pt" (default), "en", "es".

verbose

Logical. Print progress messages. Default FALSE.

Value

Depending on output_type:

  • "plot" -> a ggplot or plotly object.

  • "table" -> a tibble of the plotted data.

  • "all" -> a named list: $plot, $table, $data.

Plot types (type)

typeDescription
"importance"Horizontal bar chart of XGBoost feature Gain (top n_top features)
"fit"Observed vs. out-of-fold CV-predicted scatter with R² and RMSE annotation
"cv_log"Train/test loss per boosting round from xgb.cv(), with best-round marker

Examples

if (FALSE) { # \dontrun{
ml <- sus_mod_ml(df, outcome_col = "n_obitos", feature_cols = c("tmax", "pop"))

sus_mod_plot_ml(ml, type = "importance", lang = "pt")
sus_mod_plot_ml(ml, type = "fit",        lang = "en")
sus_mod_plot_ml(ml, type = "cv_log",     lang = "es")
out <- sus_mod_plot_ml(ml, output_type = "all")
out$table
} # }