/
algorithm-auditing.Rmd
89 lines (71 loc) · 3 KB
/
algorithm-auditing.Rmd
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
title: "Algorithm auditing: Get started"
author: Koen Derks
output:
html_document:
toc: true
toc_depth: 3
bibliography: references.bib
csl: apa.csl
vignette: >
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
nocite: |
@kozodoi_2021
---
```{r, include = FALSE}
library(jfa)
```
## Introduction
Welcome to the 'Algorithm auditing' vignette of the **jfa** package. This page
provides a guide to the functions in the package that are designed to facilitate
the audit of algorithms and predictive models. In particular, these functions
implement techniques for calculating and testing fairness metrics. The package
allows users to specify a prior probability distribution to conduct Bayesian
algorithm auditing using these functions.
## Functions and intended usage
Below you can find an explanation of the available algorithm auditing functions
in **jfa**.
- [`model_fairness()`](#testing-algorithmic-fairness)
### Testing algorithmic fairness
The `model_fairness()` function is designed to evaluate fairness in algorithmic
decision-making systems. It does this by computing and testing the equality of
various model-agnostic fairness metrics between protected classes, based on a
set of true labels and the predictions of an algorithm. The ratio of these
metrics between an unprivileged protected class and a privileged protected class
is referred to as parity, which quantifies relative fairness in the algorithm's
predictions. Available parity metrics include predictive rate parity,
proportional parity, accuracy parity, false negative rate parity, false positive
rate parity, true positive rate parity, negative predicted value parity,
specificity parity, and demographic parity [@friedler_2019; @pessach_2022]. The
function returns an object that can be used with the associated `summary()` and
`plot()` methods.
For additional details about this function, please refer to the
[function documentation](https://koenderks.github.io/jfa/reference/model_fairness.html)
on the package website.
*Example usage:*
```{r}
# Compare predictive rate parity
x <- model_fairness(
data = compas,
protected = "Ethnicity",
target = "TwoYrRecidivism",
predictions = "Predicted",
privileged = "Caucasian",
positive = "yes",
metric = "prp"
)
summary(x)
```
## Benchmarks
To ensure the accuracy of statistical results, **jfa** employs automated
[unit tests](https://github.com/koenderks/jfa/tree/development/tests/testthat)
that regularly validate the output from the package against the following
established benchmarks in the area of algorithm auditing:
- [fairness](https://cran.r-project.org/package=fairness) (R package version 1.2.2)
## Cheat sheet
The cheat sheet below will help you get started with **jfa**'s algorithm audit
functionality. A pdf version can be downloaded [here](https://github.com/koenderks/jfa/raw/development/man/figures/cheatsheet/cheatsheet-algorithm.pdf).
<p align='center'><img src='cheatsheet-algorithm.png' alt='cheatsheet-algorithm' width='1000'></p>
## References
<div id="refs"></div>