plot_group_metric: Plot group metric

Description Usage Arguments Value Examples

Description

Plot chosen metric in group. Notice how models are treating different subgroups. Compare models both in fairness metrics and in performance. Parity loss can be enabled when creating group_metric object.

Usage

1
2
## S3 method for class 'group_metric'
plot(x, ...)

Arguments

x

object of class group_metric

...

other group_metric objects and other parameters

Value

list of ggplot2 objects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)

fairmodels documentation built on May 31, 2021, 5:07 p.m.