1
|
|
|
""" |
2
|
|
|
Demographic Classification Fairness Criteria. |
3
|
|
|
|
4
|
|
|
The objectives of the demographic classification fairness criteria |
5
|
|
|
is to measure unfairness towards sensitive attribute valuse. |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
One should keep in mind that the criteria are intended |
9
|
|
|
to *measure unfairness, rather than to prove fairness*, as it stated in |
10
|
|
|
the paper `Equality of opportunity in supervised learning <https://arxiv.org/abs/1610.02413>`_ |
11
|
|
|
by Hardt et al. (2016): |
12
|
|
|
|
13
|
|
|
... satisfying [the demographic criteria] should not be |
14
|
|
|
considered a conclusive proof of fairness. |
15
|
|
|
Similarly, violations of our condition are not meant |
16
|
|
|
to be a proof of unfairness. |
17
|
|
|
Rather we envision our framework as providing a reasonable way |
18
|
|
|
of discovering and measuring potential concerns that require |
19
|
|
|
further scrutiny. We believe that resolving fairness concerns is |
20
|
|
|
ultimately impossible without substantial domain-specific |
21
|
|
|
investigation. |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
The output of binary classifiers can come in two forms, either giving |
25
|
|
|
a binary outcome prediction for input or producing |
26
|
|
|
a real number score, which the common one is the probability |
27
|
|
|
for the positive or negative label |
28
|
|
|
(such as the method ``proba`` of an ``Estimator`` in ``sklearn``). |
29
|
|
|
Therefore, the criteria come in two flavors, one for **binary** output, |
30
|
|
|
and the second for **score** output. |
31
|
|
|
|
32
|
|
|
The fundamental concept for defining the fairness criteria |
33
|
|
|
is `conditional independence <https://en.wikipedia.org/wiki/Conditional_independence>`_. |
34
|
|
|
Using *Machine Learning and Fairness* book's notions: |
35
|
|
|
|
36
|
|
|
- ``A`` - Sensitive attribute |
37
|
|
|
- ``Y`` - Binary ground truth (correct) target |
38
|
|
|
- ``R`` - Estimated binary targets or score as returned by a classifier |
39
|
|
|
|
40
|
|
|
There are three demographic fairness criteria for classification: |
41
|
|
|
|
42
|
|
|
1. Independence - R⊥A |
43
|
|
|
|
44
|
|
|
2. Separation - R⊥A∣Y |
45
|
|
|
|
46
|
|
|
3. Sufficiency - Y⊥A∣R |
47
|
|
|
|
48
|
|
|
""" |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
from ethically.fairness.metrics.binary import ( |
52
|
|
|
independence_binary, report_binary, separation_binary, sufficiency_binary, |
53
|
|
|
) |
54
|
|
|
from ethically.fairness.metrics.score import ( |
55
|
|
|
independence_score, roc_auc_score_by_attr, roc_curve_by_attr, |
56
|
|
|
separation_score, sufficiency_score, |
57
|
|
|
) |
58
|
|
|
from ethically.fairness.metrics.visualization import ( |
59
|
|
|
distplot_by, plot_roc_by_attr, plot_roc_curves, |
60
|
|
|
) |
61
|
|
|
|