View source: R/civic_data_utils.R
| civic_thresholds | R Documentation |
Computes performance metrics across a grid of decision thresholds. Essential for understanding the accuracy-vs-fairness tradeoffs that arise when choosing a classification cutoff — a DataCitizen-Pro democratic judgment teaching tool.
civic_thresholds(
y_true,
y_prob,
positive = NULL,
thresholds = seq(0.1, 0.9, by = 0.05)
)
y_true |
Factor of true class labels. |
y_prob |
Numeric vector of predicted probabilities for the positive class. |
positive |
Character. Positive class level. |
thresholds |
Numeric vector of thresholds to evaluate. Default: 'seq(0.1, 0.9, by = 0.05)'. |
A tibble with one row per threshold and columns: 'threshold', 'accuracy', 'balanced_acc', 'precision', 'recall', 'specificity', 'f1', 'rate_positive'.
y <- factor(sample(c("yes","no"), 200, replace = TRUE))
p <- runif(200)
thr <- civic_thresholds(y, p, positive = "yes")
civic_plot_thresholds(thr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.