FairPy Documentation
FairPy is a comprehensive Python Library for Machine Learning Fairness, covering various fairness notions, data structures, and learning tasks. TODO: This challenging field has many key Applications….
FairPy includes more than 10 latest fairness algorithms, such as InflFair (ICML’22) [LL22] and FairGLM (ICML’22) [DPM+22]. For consistency and accessibility, FairPy is developed on top of scikit-learn and PyTorch.
Why FairPy: Compare to Other Libraries
Attribute |
FairPy |
Fairlearn |
AI Fairness 360 |
inFairness |
---|---|---|---|---|
Group Fairness |
[x] |
[x] |
[x] |
[ ] |
Individual Fairness |
[x] |
[ ] |
[x] |
[x] |
Minimax Fairness |
[x] |
[ ] |
[ ] |
[ ] |
Tabular Data |
[x] |
[x] |
[x] |
[x] |
Graph Data |
[x] |
[ ] |
[ ] |
[ ] |
Classification |
[x] |
[x] |
[x] |
[x] |
Regression |
[x] |
[ ] |
[x] |
[ ] |
Ranking |
[x] |
[ ] |
[ ] |
[ ] |
Number of Algorithms |
10+ |
4 |
14 |
3 |
Compatible with sklearn |
[x] |
[x] |
Partially |
[ ] |
Latest release |
March 2023 |
July 2021 |
March 2021 |
June 2022 |
Sample Code of FairPy
from fairpy.dataset import Adult
from fairpy.model import LabelBias
model = LabelBias() # Choose a fairness algorithm
dataset = Adult() # Choose or customize a dataset
X, y, s = dataset.get_X_y_s() # Extract features, labels, and sensitive attributes from the dataset
model.fit(X, y, s) # Fit model with provided data
pred = model.predict(X) # Predict
Implemented Algorithms
FairPy toolkit consists of three major functional groups:
(i) Fairness Algorithms :
Type |
Name in FairPy |
Task |
Year |
Ref |
---|---|---|---|---|
Pre |
reweigh |
Any |
2012 |
[KC12] |
Pre |
LabelBias |
Classification |
2020 |
[JN20] |
Pre |
LinearFairERM |
Any |
2018 |
[DOBD+18] |
Pre |
DIRemover |
Any |
2015 |
[FFM+15] |
Pre |
IFair |
Any |
2019 |
[LGW19] |
Pre |
InflFair |
Classification |
2022 |
[LL22] |
In |
FairCstr |
Classification |
2017 |
[ZVRG17] |
In |
FairGLM |
Classification |
2022 |
[DPM+22] |
In |
FairPGRank |
Ranking |
2019 |
[SJ19] |
Post |
EqOddsCalib |
Classification |
2016 |
[HPS16] |
Post |
FairRank |
Ranking |
2017 |
[ZBC+17] |
(ii) Datasets :
Type |
Name in FairPy |
---|---|
Table |
Adult |
Table |
Bank |
Table |
Compas |
Table |
Credit |
Table |
Dutch |
Table |
German |
Table |
Oulad |
Table |
(iii) Metrics :
Type |
Name in FairPy |
---|---|
Classification |
binary_dp |
Classification |
binary_eop |
Ranking |
xAUC |
Ranking |
dcg |