fairness_radar: Fairness radar

View source: R/fairness_radar.R

fairness_radarR Documentation

Fairness radar

Description

Make fairness_radar object with chosen fairness_metrics. Note that there must be at least three metrics that does not contain NA.

Usage

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

Arguments

x

object of class fairness_object

fairness_metrics

character, vector of metric names, at least 3 metrics without NA needed. Full names of metrics can be found in fairness_check documentation.

Value

fairness_radar object. It is a list containing:

  • radar_data - data.frame containing scores for each model and parity loss metric

  • label - model labels

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"
)

fradar <- fairness_radar(fobject, fairness_metrics = c(
  "ACC", "STP", "TNR",
  "TPR", "PPV"
))

plot(fradar)


rf_model <- ranger::ranger(Risk ~ .,
  data = german,
  probability = TRUE,
  num.trees = 200,
  num.threads = 1
)


explainer_rf <- DALEX::explain(rf_model, data = german[, -1], y = y_numeric)

fobject <- fairness_check(explainer_rf, fobject)


fradar <- fairness_radar(fobject, fairness_metrics = c(
  "ACC",
  "STP",
  "TNR",
  "TPR",
  "PPV"
))

plot(fradar)



ModelOriented/FairModels documentation built on Aug. 30, 2022, 5:48 p.m.