Skip to contents

The observed frequency of presences in each bin against the mean prediction of the bin, with binomial confidence intervals (red bars) and the 1:1 line of perfect calibration (dashed); point size shows the number of points in the bin. One panel per model, labelled with the calibration slope and intercept.

Usage

plot_calibration(
  x,
  base_size = 11,
  bar_colour = "#c8553d",
  file = NULL,
  width = 2100,
  height = 1650
)

Arguments

x

A result of calibration_curve().

base_size

Base font size.

bar_colour

Colour of the confidence intervals.

file

Optional file(s) to save the plot to, e.g. "fig.pdf" or c("fig.png", "fig.pdf"); the format follows the extension, and a name without extension is saved as PNG and PDF. The plot is also returned.

width, height

Size of the saved figure in pixels (PDF and SVG at 300 pixels per inch).

Value

A ggplot object.

References

Silva Filho, T., Song, H., Perello-Nieto, M., Santos-Rodriguez, R., Kull, M., Flach, P. (2023) Classifier calibration: a survey on how to assess and improve predicted class probabilities. Machine Learning 112, 3211-3260. doi:10.1007/s10994-023-06336-7

Examples

set.seed(1)
p <- runif(2000)
plot_calibration(calibration_curve(rbinom(2000, 1, p), p))