Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate head merging #38

Merged
merged 8 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Unit Tests
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

OxonFair is an expressive toolkit designed to enforce a wide-range of fairness definitions and to customize binary classifier behavior.
The toolkit is designed to overcome a range of shortcomings in existing fairness toolkits for high-capacity models that overfit to the training data.
It is designed and works for computer vision and NLP problems alongside tabular data.
Unlike other toolkits it is designed and works for computer vision and NLP problems alongside tabular data.

Check out the colab demo [here](https://colab.research.google.com/drive/1CfcS3AX7M2MO1wW33wU1LDiY5DwtyyxH?usp=sharing) or read the [preprint](https://arxiv.org/abs/2407.13710).

Expand Down Expand Up @@ -115,6 +115,16 @@ OxonFair is build from the ground up to avoid these issues. It is a postprocessi

That said, we make several additional design decisions which we believe make for a better experience for data scientists:

#### Direct support for pytorch including NLP and Computer Vision

See [here](./examples/pytorch_minimal_demo.ipynb) for an example.
In brief, the steps are:

1. Train your network.
2. Call `DeepFairPredictor` with the network output on validation data.
3. Call `fit` to enforce fairness. Use `evaluate_groups` and `plot_frontier` to explore trade-offs.
4. Use `merge_heads_pytorch` to generate a fair network.

#### Fine-grained control of behavior

##### Wide Choice of performance measure
Expand Down
86 changes: 76 additions & 10 deletions examples/fairret.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/high-dim_fairlearn_comparision.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
76 changes: 19 additions & 57 deletions examples/multi_group_fairlearn_comparision.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"output_type": "stream",
"text": [
"Training time of xgboost without fairness\n",
"0.8215227920000006\n"
"0.6205382919999991\n"
]
}
],
Expand Down Expand Up @@ -142,8 +142,8 @@
" sensitive_features=train_data['groups'])\n",
" stop=time.perf_counter()\n",
" score=evaluate_fairness(test_data['target'], fair.predict(test_data['data']), test_data['groups'], metrics={'a':gm.accuracy,'b':gm.demographic_parity},verbose=False)\n",
" fairl[0,i]=score[0]['a']#['updated']\n",
" fairl[1,i]=score[0]['b']#['updated']\n",
" fairl[0,i]=score['a']#['updated']\n",
" fairl[1,i]=score['b']#['updated']\n",
" fairl[2,i]=stop-start\n",
" train_data['groups'][train_data['groups']==name]=' Other'\n",
" test_data['groups'][test_data['groups']==name]=' Other'"
Expand Down Expand Up @@ -224,71 +224,71 @@
" <td>OxonFair</td>\n",
" <td>0.868619</td>\n",
" <td>0.019085</td>\n",
" <td>44.246316</td>\n",
" <td>41.136526</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>FairLearn</td>\n",
" <td>0.865001</td>\n",
" <td>0.037732</td>\n",
" <td>46.683562</td>\n",
" <td>46.391113</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>OxonFair</td>\n",
" <td>0.867663</td>\n",
" <td>0.012305</td>\n",
" <td>0.816369</td>\n",
" <td>0.804408</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>FairLearn</td>\n",
" <td>0.866639</td>\n",
" <td>0.016227</td>\n",
" <td>28.097114</td>\n",
" <td>27.712763</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>OxonFair</td>\n",
" <td>0.867936</td>\n",
" <td>0.021317</td>\n",
" <td>0.067256</td>\n",
" <td>0.071277</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>FairLearn</td>\n",
" <td>0.865070</td>\n",
" <td>0.007104</td>\n",
" <td>24.851400</td>\n",
" <td>25.013719</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>OxonFair</td>\n",
" <td>0.868823</td>\n",
" <td>0.003093</td>\n",
" <td>0.053665</td>\n",
" <td>0.049922</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>FairLearn</td>\n",
" <td>0.869165</td>\n",
" <td>0.002346</td>\n",
" <td>20.321553</td>\n",
" <td>20.080540</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Accuracy Demographic Parity Time\n",
"0 OxonFair 0.868619 0.019085 44.246316\n",
"0 FairLearn 0.865001 0.037732 46.683562\n",
"1 OxonFair 0.867663 0.012305 0.816369\n",
"1 FairLearn 0.866639 0.016227 28.097114\n",
"2 OxonFair 0.867936 0.021317 0.067256\n",
"2 FairLearn 0.865070 0.007104 24.851400\n",
"3 OxonFair 0.868823 0.003093 0.053665\n",
"3 FairLearn 0.869165 0.002346 20.321553"
"0 OxonFair 0.868619 0.019085 41.136526\n",
"0 FairLearn 0.865001 0.037732 46.391113\n",
"1 OxonFair 0.867663 0.012305 0.804408\n",
"1 FairLearn 0.866639 0.016227 27.712763\n",
"2 OxonFair 0.867936 0.021317 0.071277\n",
"2 FairLearn 0.865070 0.007104 25.013719\n",
"3 OxonFair 0.868823 0.003093 0.049922\n",
"3 FairLearn 0.869165 0.002346 20.080540"
]
},
"execution_count": 7,
Expand All @@ -299,44 +299,6 @@
"source": [
"results"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\\begin{tabular}{llrrr}\n",
"\\toprule\n",
" & Name & Accuracy & Demographic Parity & Time \\\\\n",
"\\midrule\n",
"0 & OxonFair & 0.868619 & 0.019085 & 44.246316 \\\\\n",
"0 & FairLearn & 0.865001 & 0.037732 & 46.683562 \\\\\n",
"1 & OxonFair & 0.867663 & 0.012305 & 0.816369 \\\\\n",
"1 & FairLearn & 0.866639 & 0.016227 & 28.097114 \\\\\n",
"2 & OxonFair & 0.867936 & 0.021317 & 0.067256 \\\\\n",
"2 & FairLearn & 0.865070 & 0.007104 & 24.851400 \\\\\n",
"3 & OxonFair & 0.868823 & 0.003093 & 0.053665 \\\\\n",
"3 & FairLearn & 0.869165 & 0.002346 & 20.321553 \\\\\n",
"\\bottomrule\n",
"\\end{tabular}\n",
"\n"
]
}
],
"source": [
"print(results.to_latex())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading
Loading