Skip to content

Commit 887b38a

Browse files
author
simon.o'callaghan
committed
Initial commit.
1 parent 404627a commit 887b38a

10 files changed

+1123
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
# sim_algo_bias
22
Simulator code for AHRC's Addressing Algorithmic Bias tech paper.
3+
4+
The notebook `generate_scenario_figures.ipynb`generates the data, model and fairness plots in the technical paper when run.
5+
6+
7+
8+
## Installation
9+
10+
The `requirements.txt` provides the Python prerequisites for running the notebook. These can be installed in a virtualenv, for example with:
11+
12+
`pip install -r requirements.txt`
13+
14+
Then, run `jupyter notebook` from the root directory of the repository and open the notebook `generate_scenario_figures.ipynb`.

generate_scenerio_figures.ipynb

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import numpy as np\n",
10+
"import matplotlib.pyplot as plt\n",
11+
"from sklearn.metrics import confusion_matrix\n",
12+
"from src.datagen import scenarios\n",
13+
"\n",
14+
"\n",
15+
"from sklearn.linear_model import LogisticRegression\n",
16+
"import src.vis as vis\n",
17+
"import ipywidgets as widgets\n",
18+
" \n",
19+
"\n",
20+
"scale = {\n",
21+
" 'training': 1000,\n",
22+
" 'deployment': 100, \n",
23+
"} # one meeple = this many people\n",
24+
"\n",
25+
"# import bqplot.pyplot as plt\n",
26+
"# import bqplot as bq\n",
27+
"import matplotlib.pyplot as plt\n",
28+
"backend = \"matplotlib\" #bqplot\n",
29+
"%matplotlib inline\n",
30+
"\n",
31+
"%load_ext autoreload\n",
32+
"%autoreload 2"
33+
]
34+
},
35+
{
36+
"cell_type": "code",
37+
"execution_count": null,
38+
"metadata": {
39+
"scrolled": false
40+
},
41+
"outputs": [],
42+
"source": [
43+
"vis.plot_profitability_distributions(scenarios,backend)\n"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"metadata": {
50+
"scrolled": false
51+
},
52+
"outputs": [],
53+
"source": [
54+
"vis.plot_feature_importances(scenarios,backend)"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {
61+
"scrolled": false
62+
},
63+
"outputs": [],
64+
"source": [
65+
"vis.plot_fairness_metrics(scenarios,backend)"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": null,
71+
"metadata": {
72+
"scrolled": false
73+
},
74+
"outputs": [],
75+
"source": [
76+
"vis.make_fairness_maps(scenarios)"
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": null,
82+
"metadata": {},
83+
"outputs": [],
84+
"source": []
85+
}
86+
],
87+
"metadata": {
88+
"kernelspec": {
89+
"display_name": "Python 3",
90+
"language": "python",
91+
"name": "python3"
92+
},
93+
"language_info": {
94+
"codemirror_mode": {
95+
"name": "ipython",
96+
"version": 3
97+
},
98+
"file_extension": ".py",
99+
"mimetype": "text/x-python",
100+
"name": "python",
101+
"nbconvert_exporter": "python",
102+
"pygments_lexer": "ipython3",
103+
"version": "3.8.6"
104+
}
105+
},
106+
"nbformat": 4,
107+
"nbformat_minor": 4
108+
}

images/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Regenerated report images are saved here.

requirements.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
jupyter>=1.0.0
2+
numpy>=1.19.4
3+
scipy>=1.5.4
4+
pandas>=1.1.4
5+
matplotlib>=3.3.2
6+
seaborn>=0.11.0
7+
scikit-learn>=0.23.2
8+
bqplot>=0.12.5

src/__init__.py

Whitespace-only changes.
137 Bytes
Binary file not shown.
9.44 KB
Binary file not shown.

src/__pycache__/vis.cpython-38.pyc

12.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)