Learn R Programming

fairmodels (version 1.1.0)

plot.fairness_object: Plot fairness object

Description

Plot fairness check enables to look how big differences are between base subgroup (privileged) and unprivileged ones. If bar plot reaches red zone it means that for this subgroup fairness goal is not satisfied. Multiple subgroups and models can be plotted. Red and green zone boundary can be moved through epsilon parameter, that needs to be passed through fairness_check.

Usage

# S3 method for fairness_object
plot(x, ...)

Arguments

x

fairness_object object

...

other plot parameters

Value

ggplot2 object

Examples

Run this code
# NOT RUN {
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")
plot(fobject)

# }
# NOT RUN {
rf_model <- ranger::ranger(Risk ~.,
                           data = german,
                           probability = TRUE,
                           max.depth = 3,
                           num.trees = 100,
                           seed = 1)


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

fobject <- fairness_check(explainer_rf, fobject)

plot(fobject)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab