figure_dia | R Documentation |
Generates and returns a ggplot object for Receiver Operating Characteristic (ROC) curves, Precision-Recall (PRC) curves, or confusion matrices.
figure_dia(type, data, file = NULL)
type |
String, specifies the type of plot to generate. Options are "roc", "prc", or "matrix". |
data |
A list object containing model evaluation results. It must include:
|
file |
Optional. A string specifying the path to save the plot (e.g.,
"plot.png"). If |
A ggplot object. If the file
argument is provided, the plot is also
saved to the specified path.
# Create example data for a diagnostic model
external_eval_example_dia <- list(
sample_score = data.frame(
ID = paste0("S", 1:100),
label = sample(c(0, 1), 100, replace = TRUE),
score = runif(100, 0, 1)
),
evaluation_metrics = list(
Final_Threshold = 0.53
)
)
# Generate an ROC curve plot object
roc_plot <- figure_dia(type = "roc", data = external_eval_example_dia)
# To display the plot, simply run:
# print(roc_plot)
# Generate a PRC curve and save it to a temporary file
# tempfile() creates a safe, temporary path as required by CRAN
temp_prc_path <- tempfile(fileext = ".png")
figure_dia(type = "prc", data = external_eval_example_dia, file = temp_prc_path)
# Generate a Confusion Matrix plot
matrix_plot <- figure_dia(type = "matrix", data = external_eval_example_dia)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.