Learn R Programming

fairmodels (version 1.1.0)

plot.stacked_metrics: Plot stacked Metrics

Description

Stacked metrics is like plot for chosen_metric but with all unique metrics stacked on top of each other. Metrics containing NA's will be dropped to enable fair comparison.

Usage

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

Arguments

x

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

sm <- stack_metrics(fobject)
plot(sm)

# }
# NOT RUN {
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)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab