expand_fairness_object {fairmodels} | R Documentation |
Expand Fairness Object
Description
Unfold fairness object to 3 columns (metrics, label, score) to construct better base for visualization.
Usage
expand_fairness_object(
x,
scale = FALSE,
drop_metrics_with_na = FALSE,
fairness_metrics = NULL
)
Arguments
x |
object of class |
scale |
logical, if |
drop_metrics_with_na |
logical, if |
fairness_metrics |
character, vector of fairness metrics names indicating from which expand. |
Value
object of class expand_fairness_object
. It is a data.frame
with scores for each metric and model.
Examples
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"
)
expand_fairness_object(fobject, drop_metrics_with_na = TRUE)
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)
expand_fairness_object(fobject, drop_metrics_with_na = TRUE)
[Package fairmodels version 1.2.1 Index]