| group_metric | R Documentation |
Group metric enables to extract data from metrics generated for each subgroup (values in protected variable)
The closer metric values are to each other, the less bias particular model has. If parity_loss parameter is set to TRUE, distance between
privileged and unprivileged subgroups will be measured. When plotted shows both fairness metric and chosen performance metric.
group_metric(
x,
fairness_metric = NULL,
performance_metric = NULL,
parity_loss = FALSE,
verbose = TRUE
)
x |
object of class |
fairness_metric |
character, fairness metric name, if |
performance_metric |
character, performance metric name |
parity_loss |
logical, if |
verbose |
logical, whether to print information about metrics on console or not. Default |
Available metrics:
Fairness metrics (Full names explained in fairness_check documentation):
TPR: True Positive Rate
TNR: True Negative Rate
PPV: Positive Predictive Value
NPV: Negative Predictive Value
FNR: False Negative Rate
FPR: False Positive Rate
FDR: False Discovery Rate
FOR: False Omission Rate
TS: Threat Score
ACC: Accuracy
STP: Statistical Parity
F1: F1 Score
Performance metrics:
recall: Recall
precision: Precision
accuracy: Accuracy
f1: F1 Score
auc: Area Under the Curve
group_metric object.
It is a list with following items:
group_metric_data |
- |
performance_data |
- |
fairness_metric |
- name of fairness metric |
performance_metric |
- name of performance metric |
data("german")
y_numeric <- as.numeric(german$Risk) - 1
lm_model <- glm(Risk ~ .,
data = german,
family = binomial(link = "logit")
)
explainer_lm <- DALEX::explain(lm_model, data = german[, -1], y = y_numeric)
fobject <- fairness_check(explainer_lm,
protected = german$Sex,
privileged = "male"
)
gm <- group_metric(fobject, "TPR", "f1", parity_loss = TRUE)
plot(gm)
rf_model <- ranger::ranger(Risk ~ .,
data = german,
probability = TRUE,
num.trees = 200
)
explainer_rf <- DALEX::explain(rf_model, data = german[, -1], y = y_numeric)
fobject <- fairness_check(explainer_rf, fobject)
gm <- group_metric(fobject, "TPR", "f1", parity_loss = TRUE)
plot(gm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.