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

Feat/demo disparate #476

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
155 changes: 134 additions & 21 deletions examples/demo_adversarial_debiasing.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/Trusted-AI/AIF360/blob/master/examples/demo_adversarial_debiasing.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -14,14 +22,70 @@
"metadata": {},
"outputs": [
{
"name": "stderr",
"name": "stdout",
"output_type": "stream",
"text": [
"/anaconda2/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
" from ._conv import register_converters as _register_converters\n"
"Collecting aif360\n",
" Using cached aif360-0.5.0-py3-none-any.whl (214 kB)\n",
"Collecting numpy>=1.16\n",
" Downloading numpy-1.26.0-cp39-cp39-macosx_11_0_arm64.whl (14.0 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m14.0/14.0 MB\u001b[0m \u001b[31m27.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting matplotlib\n",
" Downloading matplotlib-3.8.0-cp39-cp39-macosx_11_0_arm64.whl (7.5 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.5/7.5 MB\u001b[0m \u001b[31m25.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting scipy>=1.2.0\n",
" Using cached scipy-1.11.2-cp39-cp39-macosx_12_0_arm64.whl (29.6 MB)\n",
"Collecting scikit-learn>=1.0\n",
" Downloading scikit_learn-1.3.1-cp39-cp39-macosx_12_0_arm64.whl (9.5 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m9.5/9.5 MB\u001b[0m \u001b[31m28.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting pandas>=0.24.0\n",
" Downloading pandas-2.1.1-cp39-cp39-macosx_11_0_arm64.whl (10.9 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.9/10.9 MB\u001b[0m \u001b[31m28.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting pytz>=2020.1\n",
" Using cached pytz-2023.3.post1-py2.py3-none-any.whl (502 kB)\n",
"Collecting tzdata>=2022.1\n",
" Using cached tzdata-2023.3-py2.py3-none-any.whl (341 kB)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /Users/asmitahajra/.pyenv/versions/3.9.16/lib/python3.9/site-packages (from pandas>=0.24.0->aif360) (2.8.2)\n",
"Collecting threadpoolctl>=2.0.0\n",
" Using cached threadpoolctl-3.2.0-py3-none-any.whl (15 kB)\n",
"Collecting joblib>=1.1.1\n",
" Using cached joblib-1.3.2-py3-none-any.whl (302 kB)\n",
"Collecting contourpy>=1.0.1\n",
" Downloading contourpy-1.1.1-cp39-cp39-macosx_11_0_arm64.whl (232 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m232.6/232.6 KB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hCollecting fonttools>=4.22.0\n",
" Using cached fonttools-4.42.1-cp39-cp39-macosx_10_9_universal2.whl (2.7 MB)\n",
"Requirement already satisfied: packaging>=20.0 in /Users/asmitahajra/.pyenv/versions/3.9.16/lib/python3.9/site-packages (from matplotlib->aif360) (23.0)\n",
"Collecting pyparsing>=2.3.1\n",
" Using cached pyparsing-3.1.1-py3-none-any.whl (103 kB)\n",
"Collecting importlib-resources>=3.2.0\n",
" Downloading importlib_resources-6.1.0-py3-none-any.whl (33 kB)\n",
"Collecting cycler>=0.10\n",
" Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)\n",
"Collecting pillow>=6.2.0\n",
" Downloading Pillow-10.0.1-cp39-cp39-macosx_11_0_arm64.whl (3.3 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.3/3.3 MB\u001b[0m \u001b[31m24.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting kiwisolver>=1.0.1\n",
" Using cached kiwisolver-1.4.5-cp39-cp39-macosx_11_0_arm64.whl (66 kB)\n",
"Requirement already satisfied: zipp>=3.1.0 in /Users/asmitahajra/.pyenv/versions/3.9.16/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib->aif360) (3.15.0)\n",
"Requirement already satisfied: six>=1.5 in /Users/asmitahajra/.pyenv/versions/3.9.16/lib/python3.9/site-packages (from python-dateutil>=2.8.2->pandas>=0.24.0->aif360) (1.14.0)\n",
"Installing collected packages: pytz, tzdata, threadpoolctl, pyparsing, pillow, numpy, kiwisolver, joblib, importlib-resources, fonttools, cycler, scipy, pandas, contourpy, scikit-learn, matplotlib, aif360\n",
"Successfully installed aif360-0.5.0 contourpy-1.1.1 cycler-0.11.0 fonttools-4.42.1 importlib-resources-6.1.0 joblib-1.3.2 kiwisolver-1.4.5 matplotlib-3.8.0 numpy-1.26.0 pandas-2.1.1 pillow-10.0.1 pyparsing-3.1.1 pytz-2023.3.post1 scikit-learn-1.3.1 scipy-1.11.2 threadpoolctl-3.2.0 tzdata-2023.3\n",
"\u001b[33mWARNING: You are using pip version 22.0.4; however, version 23.2.1 is available.\n",
"You should consider upgrading via the '/Users/asmitahajra/.pyenv/versions/3.9.16/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\u001b[33m\n",
"\u001b[0m"
]
}
],
"source": [
"!pip install aif360"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"# Load all necessary packages\n",
Expand All @@ -48,6 +112,50 @@
"tf.disable_eager_execution()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: wget in /Users/asmitahajra/.pyenv/versions/3.9.16/lib/python3.9/site-packages (3.2)\n",
"\u001b[33mWARNING: You are using pip version 22.0.4; however, version 23.2.1 is available.\n",
"You should consider upgrading via the '/Users/asmitahajra/.pyenv/versions/3.9.16/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\u001b[33m\n",
"\u001b[0m"
]
}
],
"source": [
"!pip install wget\n",
"!wget -q \thttps://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data\n",
"!wget -q \thttps://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.test\n",
"!wget -q \thttps://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.names"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mv: rename /content/adult.data to /usr/local/lib/python3.10/dist-packages/aif360/data/raw/adult/: No such file or directory\n",
"mv: rename /content/adult.test to /usr/local/lib/python3.10/dist-packages/aif360/data/raw/adult/: No such file or directory\n",
"mv: rename /content/adult.names to /usr/local/lib/python3.10/dist-packages/aif360/data/raw/adult/: No such file or directory\n"
]
}
],
"source": [
"! mv /content/adult.data /usr/local/lib/python3.10/dist-packages/aif360/data/raw/adult/\n",
"! mv /content/adult.test /usr/local/lib/python3.10/dist-packages/aif360/data/raw/adult/\n",
"! mv /content/adult.names /usr/local/lib/python3.10/dist-packages/aif360/data/raw/adult/"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -57,7 +165,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -72,7 +180,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -195,7 +303,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -234,7 +342,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -282,7 +390,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -298,7 +406,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -426,7 +534,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -437,7 +545,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -525,7 +633,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -536,7 +644,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -550,7 +658,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -684,7 +792,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -695,7 +803,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -858,21 +966,26 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.15"
"pygments_lexer": "ipython3",
"version": "3.9.16"
},
"vscode": {
"interpreter": {
"hash": "734177c561256b469e59a47f4edca63f7e20809b64ad4d554c2dec92455ee3e2"
}
}
},
"nbformat": 4,
Expand Down
96 changes: 89 additions & 7 deletions examples/demo_calibrated_eqodds_postprocessing.ipynb

Large diffs are not rendered by default.

Loading