
Plot Diagnostic and Validation Graphs for YOLO Test Results
Source:R/utils_yolo_test.R
plot.yolo_test.RdGenerates publication-ready diagnostic plots for an evaluated YOLO model on the test dataset:
which = "all": A 4-panel dashboard containing Confusion Matrix, Count Validation Scatter, Precision-Recall Curve, and IoU Distribution.which = "confusion": Formatted heat map of the Confusion Matrix (normalized or counts).which = "counts": Ground Truth vs. Predicted Count regression scatter plot with 1:1 diagonal and \(R^2\).which = "pr": Precision-Recall curve with shaded area under curve.which = "iou": Histogram and density distribution of True Positive IoU overlap values.which = "f1": F1-score across confidence thresholds curve.
You can also pass multiple choices to which (e.g. which = c("confusion", "counts")).
Usage
# S3 method for class 'yolo_test'
plot(
x,
which = c("all", "confusion", "counts", "pr", "iou", "f1"),
ncol = NULL,
nrow = NULL,
digits = 3,
normalized = TRUE,
bg = "white",
col_cm = c("#f0fdf4", "#86efac", "#22c55e", "#15803d"),
col_cm_error = c("#fff1f2", "#fecdd3", "#f43f5e", "#be123c"),
col_points = "#4f46e5",
col_line = "#2563eb",
col_ideal = "#94a3b8",
col_pr = "#059669",
col_iou = "#3b82f6",
col_f1 = "#7c3aed",
grid = TRUE,
col_grid = "#e2e8f0",
mar = c(4.2, 5.2, 3.2, 1.5),
mgp = c(2.2, 0.7, 0),
cex.main = 1.15,
cex.lab = 1,
cex.axis = 0.85,
font.main = 2,
save = FALSE,
file_name = NULL,
width = NULL,
height = NULL,
dpi = 300,
...
)Arguments
- x
An object of class
yolo_test(produced byyolo_model_test()).- which
Character vector specifying which plot(s) to render:
"all"(default), or any combination of"confusion","counts","pr","iou", and"f1".- ncol
Optional integer. Number of columns in the plot grid. If
NULL(default), automatically computed based on the number of plots.- nrow
Optional integer. Number of rows in the plot grid. If
NULL(default), automatically computed based on the number of plots andncol.- digits
Integer. Number of decimal digits for displaying statistics in plot titles, legends, regression equations, and confusion matrix cells (default
3).- normalized
Logical. If
TRUE(default), plots normalized confusion matrix frequencies (0 to 1).- bg
Character string. Background color for plots (default
"#fafafa").- col_cm
Character vector of colors for the diagonal of the confusion matrix (correct detections). Defaults to an emerald green palette.
- col_cm_error
Character vector of colors for off-diagonal cells (misclassifications/errors). Defaults to a rose red palette.
- col_points
Character string. Fill color for scatter points in count validation (default
"#4f46e5").- col_line
Character string. Color for linear regression line (default
"#2563eb").- col_ideal
Character string. Color for 1:1 identity dashed line (default
"#94a3b8").- col_pr
Character string. Color for Precision-Recall curve (default
"#059669").- col_iou
Character string. Color for IoU distribution histogram bars (default
"#3b82f6").- col_f1
Character string. Color for F1-Confidence curve (default
"#7c3aed").- grid
Logical. Whether to display subtle background grid lines (default
TRUE).- col_grid
Character string. Grid line color (default
"#e2e8f0").- mar
Numeric vector of length 4. Margins for subplots (default
c(4.2, 4.5, 3.2, 1.5)).- mgp
Numeric vector of length 3. Margin line for axis title, labels and line (default
c(2.2, 0.7, 0)).- cex.main
Numeric. Magnification for main titles (default
1.15).- cex.lab
Numeric. Magnification for x and y labels (default
1.0).- cex.axis
Numeric. Magnification for axis tick labels (default
0.85).- font.main
Integer. Font style for titles (default
2, bold).- save
Logical. If
TRUE, saves the generated plot to an image or document file (defaultFALSE).- file_name
Optional character string. Custom file name or path to save the plot (e.g.
"test_dashboard.png","fig_counts.pdf"). IfNULLandsave = TRUE, a default descriptive name is generated based on the model and selected plots.- width
Numeric. Width of the output plot in inches (or pixels if > 50). If
NULL, automatically computed based on the number of subplot columns.- height
Numeric. Height of the output plot in inches (or pixels if > 50). If
NULL, automatically computed based on the number of subplot rows.- dpi
Numeric. Resolution in dots per inch (DPI) for bitmap devices (default
300).- ...
Additional arguments passed to base graphics functions.