Creates a reliability diagram (calibration plot) showing the relationship between predicted probabilities and observed frequencies.
Usage
plot_calibration(
calib_result,
show_histogram = TRUE,
by_cluster = FALSE,
title = "Calibration Plot",
...
)Arguments
- calib_result
Result from
compute_calibration.- show_histogram
Logical. If TRUE, show histogram of predictions below the calibration curve. Default: TRUE.
- by_cluster
Logical. If TRUE, show separate curves for each cluster. If FALSE, aggregate across clusters. Default: FALSE.
- title
Character. Plot title. Default: "Calibration Plot".
- ...
Additional arguments passed to ggplot2 functions.
Details
A reliability diagram plots mean predicted probability (x-axis) against mean observed frequency (y-axis) for each bin. A perfectly calibrated model follows the diagonal line (y = x). Points above the diagonal indicate underconfidence; points below indicate overconfidence.
The shaded band around the diagonal shows +/- 0.1 deviation as a reference. The ECE value is displayed in the plot subtitle.
Examples
if (FALSE) { # \dontrun{
calib <- compute_calibration(fit$resp, z_true)
# Basic calibration plot
p <- plot_calibration(calib)
print(p)
# Show by cluster
p <- plot_calibration(calib, by_cluster = TRUE)
print(p)
# Save to file
ggsave("calibration.pdf", p, width = 6, height = 5)
} # }