plot_fairmodels: Plot fairmodels

View source: R/plot_fairmodels.R

plot_fairmodelsR Documentation

Plot fairmodels

Description

Easier access to all plots in fairmodels. Provide plot type (that matches to function name), pass additional parameters and plot.

Usage

plot_fairmodels(x, type, ...)

## S3 method for class 'explainer'
plot_fairmodels(x, type = "fairness_check", ..., protected, privileged)

## S3 method for class 'fairness_object'
plot_fairmodels(x, type = "fairness_check", ...)

## Default S3 method:
plot_fairmodels(x, type = "fairness_check", ...)

Arguments

x

object created with fairness_check or with explain

type

character, type of plot. Should match function name in fairmodels. Default is fairness_check.

...

other parameters passed to fairmodels functions.

protected

factor, vector containing sensitive attributes such as gender, race, etc...

privileged

character/factor, level in factor denoting privileged subgroup

Details

types (function names) available:

  • fairness_check

  • stack_metrics

  • fairness_heatmap

  • fairness_pca

  • fairness_radar

  • group_metric

  • choose_metric

  • metric_scores

  • performance_and_fairness

  • all_cutoffs

  • ceteris_paribus_cutoff

Value

ggplot2 object

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)

# works with explainer when protected and privileged are passed
plot_fairmodels(explainer_lm,
  type = "fairness_radar",
  protected = german$Sex,
  privileged = "male"
)

# or with fairness_object
fobject <- fairness_check(explainer_lm,
  protected = german$Sex,
  privileged = "male"
)

plot_fairmodels(fobject, type = "fairness_radar")

fairmodels documentation built on Aug. 24, 2022, 1:05 a.m.