calc_balanced_precision {mikropml} | R Documentation |
Calculate balanced precision given actual and baseline precision
Description
Implements Equation 1 from Wu et al. 2021 doi:10.1016/j.ajhg.2021.08.012.
It is the same as Equation 7 if AUPRC
(aka prAUC
) is used in place of precision
.
Usage
calc_balanced_precision(precision, prior)
Arguments
precision |
actual precision of the model. |
prior |
baseline precision, aka frequency of positives. Can be calculated with calc_baseline_precision |
Value
the expected precision if the data were balanced
Author(s)
Kelly Sovacool sovacool@umich.edu
Examples
prior <- calc_baseline_precision(otu_mini_bin,
outcome_colname = "dx",
pos_outcome = "cancer"
)
calc_balanced_precision(otu_mini_bin_results_rf$performance$Precision, prior)
otu_mini_bin_results_rf$performance %>%
dplyr::mutate(
balanced_precision = calc_balanced_precision(Precision, prior),
aubprc = calc_balanced_precision(prAUC, prior)
) %>%
dplyr::select(AUC, Precision, balanced_precision, aubprc)
# cumulative performance for a single model
sensspec_1 <- calc_model_sensspec(
otu_mini_bin_results_glmnet$trained_model,
otu_mini_bin_results_glmnet$test_data,
"dx"
)
head(sensspec_1)
prior <- calc_baseline_precision(otu_mini_bin,
outcome_colname = "dx",
pos_outcome = "cancer"
)
sensspec_1 %>%
dplyr::mutate(balanced_precision = calc_balanced_precision(precision, prior)) %>%
dplyr::rename(recall = sensitivity) %>%
calc_mean_perf(group_var = recall, sum_var = balanced_precision) %>%
plot_mean_prc(ycol = mean_balanced_precision)
[Package mikropml version 1.6.1 Index]