stack_metrics {fairmodels}R Documentation

Stack metrics

Description

Stack metrics sums parity loss metrics for all models. Higher value of stacked metrics means the model is less fair (has higher bias) for subgroups from protected vector.

Usage

stack_metrics(x, fairness_metrics = c("ACC", "TPR", "PPV", "FPR", "STP"))

Arguments

x

object of class fairness_object

fairness_metrics

character, vector of fairness parity_loss metric names to include in plot. Full names are provided in fairess_check documentation.

Value

stacked_metrics object. It contains data.frame with information about score 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"
)

sm <- stack_metrics(fobject)
plot(sm)


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)

sm <- stack_metrics(fobject)
plot(sm)



[Package fairmodels version 1.2.1 Index]