set.seed(42)
# imbalanced labels
labels = sample(c(0,1), 100, replace = TRUE, prob = c(0.8,0.2))
# predictions
preds = rnorm(100)
# get CIs for PR curve
pr_tbl = pr.boot(labels, preds, boot.n = 100, x_bins = 30) # default x_bin is 1000
pr_tbl
# draw PR curve + add the bootstrap percentile confidence bands
library(ggplot2)
pr_tbl |>
ggplot(aes(x = recall, y = precision)) +
geom_step() +
ylim(c(0,1)) +
geom_ribbon(aes(ymin = precision_low, ymax = precision_high), alpha = 0.2)
Run the code above in your browser using DataLab