{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# uncomment and install dependencies before continuing\n", "# !pip install --upgrade inFairness requests tqdm" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/mayank/opt/anaconda3/envs/infairness/lib/python3.8/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] } ], "source": [ "import torch\n", "import torch.nn as nn\n", "import torch.nn.functional as F\n", "\n", "from torch.utils.data import Dataset\n", "from torch.utils.data import DataLoader\n", "from tqdm.auto import tqdm\n", "\n", "from inFairness.fairalgo import SenSeI\n", "from inFairness import distances\n", "from inFairness.auditor import SenSRAuditor, SenSeIAuditor\n", "\n", "%load_ext autoreload\n", "%autoreload 2\n", "\n", "import data\n", "import metrics" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "class AdultDataset(Dataset):\n", " def __init__(self, data, labels):\n", " self.data = data\n", " self.labels = labels\n", "\n", " def __getitem__(self, idx):\n", " data = self.data[idx]\n", " label = self.labels[idx]\n", " return data, label\n", " \n", " def __len__(self):\n", " return len(self.labels)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | age | \n", "capital-gain | \n", "capital-loss | \n", "education-num | \n", "hours-per-week | \n", "marital-status_Divorced | \n", "marital-status_Married-AF-spouse | \n", "marital-status_Married-civ-spouse | \n", "marital-status_Married-spouse-absent | \n", "marital-status_Never-married | \n", "... | \n", "relationship_Own-child | \n", "relationship_Unmarried | \n", "relationship_Wife | \n", "workclass_Federal-gov | \n", "workclass_Local-gov | \n", "workclass_Private | \n", "workclass_Self-emp-inc | \n", "workclass_Self-emp-not-inc | \n", "workclass_State-gov | \n", "workclass_Without-pay | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0.409331 | \n", "-0.14652 | \n", "-0.218253 | \n", "-1.613806 | \n", "-0.496770 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "... | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
1 | \n", "-1.104187 | \n", "-0.14652 | \n", "-0.218253 | \n", "-0.050064 | \n", "-1.741764 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "... | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
2 | \n", "1.393118 | \n", "-0.14652 | \n", "-0.218253 | \n", "-0.440999 | \n", "2.574214 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
3 | \n", "-0.423104 | \n", "-0.14652 | \n", "-0.218253 | \n", "-0.440999 | \n", "1.163221 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
4 | \n", "-0.877159 | \n", "-0.14652 | \n", "-0.218253 | \n", "1.122743 | \n", "0.748224 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "
5 rows × 39 columns
\n", "