pr.boot | R Documentation |
This functions calculates bootstrap percentile CIs for PR curves using precrec. These can then be used in a plotting function, see example.
pr.boot(
labels,
preds,
boot.n = 10000,
boot.stratified = TRUE,
alpha = 0.1,
...
)
labels |
( |
preds |
( |
boot.n |
( |
boot.stratified |
( |
alpha |
( |
... |
Other parameters to pass on to precrec::evalmod, except |
A tibble with columns:
recall
: recall of original data
precision
: precision of original data
low_precision
: low value of the bootstrap confidence interval
high_precision
: high value of the bootstrap confidence interval
Saito, Takaya, Rehmsmeier, Marc (2016). “Precrec: fast and accurate precision-recall and ROC curve calculations in R.” Bioinformatics, 33(1), 145–147. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/bioinformatics/btw570")}.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.