View source: R/pred_rate_parity.R
pred_rate_parity | R Documentation |
This function computes the Predictive Rate Parity metric.
Formula: TP / (TP + FP)
pred_rate_parity(
data,
outcome,
group,
probs = NULL,
preds = NULL,
outcome_base = NULL,
cutoff = 0.5,
base = NULL,
group_breaks = NULL
)
data |
Data.frame that contains the necessary columns. |
outcome |
Column name indicating the binary outcome variable (character). |
group |
Column name indicating the sensitive group (character). |
probs |
Column name or vector with the predicted probabilities (numeric between 0 - 1). Either probs or preds need to be supplied. |
preds |
Column name or vector with the predicted binary outcome (0 or 1). Either probs or preds need to be supplied. |
outcome_base |
Base level of the outcome variable (i.e., negative class). Default is the first level of the outcome variable. |
cutoff |
Cutoff to generate predicted outcomes from predicted probabilities. Default set to 0.5. |
base |
Base level of the sensitive group (character). |
group_breaks |
If group is continuous (e.g., age): either a numeric vector of two or more unique cut points or a single number >= 2 giving the number of intervals into which group feature is to be cut. |
This function computes the Predictive Rate Parity metric (also known as Sufficiency) as described by Zafar et al., 2017. Predictive rate parity is calculated by the division of true positives with all observations predicted positives. This metrics equals to what is traditionally known as precision or positive predictive value. In the returned named vector, the reference group will be assigned 1, while all other groups will be assigned values according to whether their precisions are lower or higher compared to the reference group. Lower precisions will be reflected in numbers lower than 1 in the returned named vector, thus numbers lower than 1 mean WORSE prediction for the subgroup.
Metric |
Raw precision metrics for all groups and metrics standardized for the base group (predictive rate parity metric). Lower values compared to the reference group mean lower precisions in the selected subgroups |
Metric_plot |
Bar plot of Predictive Rate Parity metric |
Probability_plot |
Density plot of predicted probabilities per subgroup. Only plotted if probabilities are defined |
data(compas)
compas$Two_yr_Recidivism_01 <- ifelse(compas$Two_yr_Recidivism == 'yes', 1, 0)
pred_rate_parity(data = compas, outcome = 'Two_yr_Recidivism_01', group = 'ethnicity',
probs = 'probability', cutoff = 0.4, base = 'Caucasian')
pred_rate_parity(data = compas, outcome = 'Two_yr_Recidivism_01', group = 'ethnicity',
preds = 'predicted', cutoff = 0.5, base = 'Hispanic')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.