{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`ProPublica Recidivism/COMPAS` :<br>\n",
    "    The COMPAS dataset (Correctional Offender Management Profiling for Alternative Sanctions) is a dataset used for binary classification tasks in the field of criminal justice. The goal is to predict whether a defendant will re-offend within two years of release, based on various demographic and criminal history features.<br>\n",
    "    Reference Link: https://www.propublica.org/datastore/dataset/compas-recidivism-risk-score-data-and-analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "import os\n",
    "import sys\n",
    "module_path = os.path.abspath(os.path.join('..', '..'))\n",
    "if module_path not in sys.path:\n",
    "    sys.path.append(module_path)\\\n",
    "\n",
    "import facts\n",
    "from facts.clean import clean_dataset\n",
    "from facts import valid_ifthens_with_coverage_correctness, rules2rulesbyif\n",
    "from facts.models import customLogisticRegression\n",
    "from facts.parameters import ParameterProxy\n",
    "from facts.formatting import recourse_report_reverse, print_recourse_report, print_recourse_report_cumulative, print_recourse_report_KStest_cumulative\n",
    "from facts.utils import load_rules_by_if\n",
    "from aif360.sklearn.datasets import fetch_compas\n",
    "from facts.fairness_metrics_aggr import get_diff_table, get_comb_df, get_analysis_dfs, get_diff_real_diff_drop,get_other_ranks_divided,get_map_metric_to_max_rank\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "computed_rules_file = Path(\"..\") / \"..\" / \"Pre-computed Results\" / \"Compas\" / \"rulesCompas_atomic.data\"\n",
    "computed_rules_with_cumulative_file = Path(\"..\") / \"..\" / \"Pre-computed Results\" / \"Compas\" / \"rulesCompas_cumulative.data\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "cost_budget = 10\n",
    "top_count = 20\n",
    "c_inf = 5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sex</th>\n",
       "      <th>age_cat</th>\n",
       "      <th>race</th>\n",
       "      <th>juv_fel_count</th>\n",
       "      <th>juv_misd_count</th>\n",
       "      <th>juv_other_count</th>\n",
       "      <th>priors_count</th>\n",
       "      <th>c_charge_degree</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Male</td>\n",
       "      <td>Greater than 45</td>\n",
       "      <td>Other</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>(-0.1, 1.0]</td>\n",
       "      <td>F</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Male</td>\n",
       "      <td>25 - 45</td>\n",
       "      <td>African-American</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>(-0.1, 1.0]</td>\n",
       "      <td>F</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Male</td>\n",
       "      <td>10-25</td>\n",
       "      <td>African-American</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>(1.0, 5.0]</td>\n",
       "      <td>F</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Male</td>\n",
       "      <td>25 - 45</td>\n",
       "      <td>Other</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>(-0.1, 1.0]</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Male</td>\n",
       "      <td>25 - 45</td>\n",
       "      <td>Caucasian</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>(10.0, 15.0]</td>\n",
       "      <td>F</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    sex          age_cat              race  juv_fel_count  juv_misd_count  \\\n",
       "0  Male  Greater than 45             Other              0               0   \n",
       "1  Male          25 - 45  African-American              0               0   \n",
       "2  Male            10-25  African-American              0               0   \n",
       "3  Male          25 - 45             Other              0               0   \n",
       "4  Male          25 - 45         Caucasian              0               0   \n",
       "\n",
       "   juv_other_count  priors_count c_charge_degree  \n",
       "0                0   (-0.1, 1.0]               F  \n",
       "1                0   (-0.1, 1.0]               F  \n",
       "2                1    (1.0, 5.0]               F  \n",
       "3                0   (-0.1, 1.0]               M  \n",
       "4                0  (10.0, 15.0]               F  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X, y = fetch_compas()\n",
    "X['target'] = y.values\n",
    "\n",
    "sensitive_attribute = \"race\"\n",
    "df = clean_dataset(X,'compas')\n",
    "y = df['target']\n",
    "X = df.drop('target', axis=1)\n",
    "\n",
    "X.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "rules_with_atomic_correctness = load_rules_by_if(computed_rules_file)\n",
    "rules_with_cumulative_correctness = load_rules_by_if(computed_rules_with_cumulative_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "num_features = X._get_numeric_data().columns.to_list()\n",
    "cate_features = X.select_dtypes(include=['object','category']).columns.to_list()\n",
    "ord_features = []\n",
    "feature_weights = {'sex':100,\t'age_cat':10,\t'race':100,\t'juv_fel_count':1,\t'juv_fel_count':1,\t'juv_other_count':1,\t'priors_count':1,\t'c_charge_degree':1}\n",
    "\n",
    "features_with_binary_cost = cate_features\n",
    "features_with_proportional_cost = num_features\n",
    "\n",
    "\n",
    "comparators = facts.feature_change_builder(\n",
    "    X,\n",
    "    num_cols=features_with_proportional_cost,\n",
    "    cate_cols=features_with_binary_cost,\n",
    "    ord_cols=ord_features,\n",
    "    feature_weights=feature_weights,\n",
    "    num_normalization=False,\n",
    "    #feats_to_normalize = [\"capital-gain\",\"capital-loss\"]\n",
    ")\n",
    "params = ParameterProxy(featureChanges=comparators)\n",
    "facts.update_costs_cumulative(rules_with_cumulative_correctness, params)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Macro Viewpoint"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Equal Cost of Effectiveness (Macro)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_fel_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m21.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m71.43%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m20.89%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m90.74%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 9.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m21.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m73.17%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m20.12%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m73.08%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m93.27%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 9.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, priors_count = (5.0, 10.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.56%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.51%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m84.62%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m92.31%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m84.62%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m11.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 9.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m7.18%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m71.43%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m9.48%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m85.71%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 8.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m33.33%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m83.08%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.31%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m25.73%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m86.47%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 1.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, sex = Female\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m11.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.55%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m87.50%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 1.\u001b[39m\n",
      "If \u001b[1mpriors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m42.05%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.49%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m28.63%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m70.95%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\t\u001b[35mNo bias!\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m38.46%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m90.67%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m33.08%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m85.96%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mNo bias!\u001b[39m\n"
     ]
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset(\n",
    "    rules_with_atomic_correctness,\n",
    "    metric=\"min-above-thr\",\n",
    "    sort_strategy=\"generic-sorting-ignore-exists-subgroup-empty\",\n",
    "    top_count=50,\n",
    "    cor_threshold=0.7,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        \"remove-below-thr\",\n",
    "        # \"remove-fair-rules\",\n",
    "        \"keep-only-min-change\"\n",
    "    ],\n",
    "    params=params\n",
    ")\n",
    "\n",
    "print_recourse_report(\n",
    "    top_rules,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    metric_name = 'Equal Cost of Effectiveness (threshold = 0.7)'\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Equal Choice for Recourse(Macro)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_other_count = 1\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-3.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.87%\u001b[39m covered\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\u001b[39m\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 3.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, sex = Female\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.55%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m87.50%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m87.50%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-4.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 3.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_misd_count = 1\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\u001b[39m\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.29%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m76.47%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m82.35%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m88.24%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-3.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 3.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = M, juv_misd_count = 0, priors_count = (10.0, 15.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = F\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-7.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.16%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m83.33%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m83.33%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-4.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 3.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, juv_misd_count = 1, priors_count = (5.0, 10.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\u001b[39m\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.93%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m90.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m70.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-3.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 3.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m33.33%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m93.85%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m83.08%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.31%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-3.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m25.73%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m86.47%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-1.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 2.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_fel_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m21.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m92.86%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m71.43%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m92.86%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m95.24%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m71.43%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-5.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m20.89%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m90.74%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m90.74%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m92.59%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-3.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 2.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m7.18%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m71.43%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m71.43%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-8.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m9.48%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m87.76%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m93.88%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m85.71%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m93.88%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-6.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 2.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, priors_count = (5.0, 10.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.56%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-8.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.51%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m84.62%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m92.31%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m92.31%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m92.31%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m84.62%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m92.31%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-6.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 2.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, priors_count = (5.0, 10.0], sex = Female\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-2.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.51%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m76.92%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m92.31%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-4.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 2.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, juv_misd_count = 0, sex = Female\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\u001b[39m\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.93%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-2.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 2.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m46.67%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.53%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m47.97%\u001b[39m covered\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\u001b[39m\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 1.\u001b[39m\n",
      "If \u001b[1mpriors_count = (1.0, 5.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m40.00%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m79.49%\u001b[39m.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m-1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m26.50%\u001b[39m covered\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\u001b[39m\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 1.\u001b[39m\n"
     ]
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset(\n",
    "    rules_with_atomic_correctness,\n",
    "    metric=\"num-above-thr\",\n",
    "    sort_strategy=\"generic-sorting-ignore-forall-subgroups-empty\",\n",
    "    top_count=50,\n",
    "    cor_threshold=0.7,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        \"remove-below-thr\",\n",
    "        # \"remove-fair-rules\"\n",
    "    ],\n",
    "    params=params\n",
    ")\n",
    "\n",
    "print_recourse_report(\n",
    "    top_rules,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    metric_name = 'Equal Choice for Recourse (threshold = 0.7)'\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Micro Viewpoint"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Equal Conditional Mean Recourse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_other_count = 2\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.55%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m12.50%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m9.50\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Conditional Mean Recourse. Unfairness score = 7.5.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, juv_misd_count = 0, juv_other_count = 1, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 11.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m11.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.87%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m20.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m35.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m5.29\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Conditional Mean Recourse. Unfairness score = 5.714.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, juv_other_count = 1, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m3.08%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m5.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.93%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m20.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m20.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m9.20\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Conditional Mean Recourse. Unfairness score = 4.2.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, juv_other_count = 1, priors_count = (-0.1, 1.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m3.08%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m6.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.32%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.17\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Conditional Mean Recourse. Unfairness score = 4.167.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_fel_count = 0, juv_misd_count = 1, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m11.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.71%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m42.86%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m42.86%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m92.86%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m92.86%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m92.86%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m6.85\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Conditional Mean Recourse. Unfairness score = 4.154.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 1\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.68%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m31.58%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m36.84%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m52.63%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m5.90\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Conditional Mean Recourse. Unfairness score = 3.9.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_other_count = 1, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.68%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m26.32%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m26.32%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m42.11%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m5.75\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Conditional Mean Recourse. Unfairness score = 3.75.\u001b[39m\n"
     ]
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset_cumulative(\n",
    "    rules_with_cumulative_correctness,\n",
    "    metric=\"fairness-of-mean-recourse-conditional\",\n",
    "    sort_strategy=\"generic-sorting-ignore-exists-subgroup-empty\",\n",
    "    top_count=top_count,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        \"remove-fair-rules\"\n",
    "    ],\n",
    "    params=params\n",
    ")\n",
    "\n",
    "print_recourse_report_cumulative(\n",
    "    top_rules,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    show_then_costs=True,\n",
    "    metric_name = 'Equal Conditional Mean Recourse'\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Equal Cost of Effectiveness (Micro)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_fel_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m21.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m71.43%\u001b[39m and counterfactual cost = 1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m20.89%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m67.59%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m67.59%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m90.74%\u001b[39m and counterfactual cost = 10.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 9.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m21.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m73.17%\u001b[39m and counterfactual cost = 1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m20.12%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m64.42%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m73.08%\u001b[39m and counterfactual cost = 10.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 9.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, priors_count = (5.0, 10.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.56%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m40.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.51%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m15.38%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m69.23%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m69.23%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m84.62%\u001b[39m and counterfactual cost = 11.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m11.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 9.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m7.18%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m21.43%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m71.43%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m9.48%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m18.37%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m63.27%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m63.27%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m85.71%\u001b[39m and counterfactual cost = 10.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 8.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m33.33%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.31%\u001b[39m and counterfactual cost = 1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m25.73%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m53.38%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m69.92%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m86.47%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 1.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, sex = Female\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m11.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.55%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m12.50%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m87.50%\u001b[39m and counterfactual cost = 10.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Cost of Effectiveness (threshold = 0.7). Unfairness score = 1.\u001b[39m\n"
     ]
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset_cumulative(\n",
    "    rules_with_cumulative_correctness,\n",
    "    metric=\"min-above-corr\",\n",
    "    sort_strategy=\"generic-sorting-ignore-exists-subgroup-empty\",\n",
    "    top_count=top_count,\n",
    "    cor_threshold = 0.7,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        \"remove-fair-rules\",\n",
    "        \"keep-cheap-rules-above-thr-cor\",\n",
    "        \n",
    "        \n",
    "    ],\n",
    "    params=params\n",
    ")\n",
    "\n",
    "print_recourse_report_cumulative(\n",
    "    top_rules,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    show_then_costs=True,\n",
    "    metric_name = 'Equal Cost of Effectiveness (threshold = 0.7)'\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Equal Effectiveness"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mjuv_other_count = 3\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 3.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.67\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.16%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.667.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_fel_count = 0, juv_misd_count = 1\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.50\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.90%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m40.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m46.67%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m93.33%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m93.33%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m93.33%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.93\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.433.\u001b[39m\n",
      "If \u001b[1mjuv_other_count = 1, priors_count = (-0.1, 1.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m3.08%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.50\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.32%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.08\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.417.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_misd_count = 0, juv_other_count = 1\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.75\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.32%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m33.33%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m33.33%\u001b[39m and counterfactual cost = 11.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m33.33%\u001b[39m and counterfactual cost = 12.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.33\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.417.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, juv_other_count = 1\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.75\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m6.38%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m15.15%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m33.33%\u001b[39m and counterfactual cost = 11.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.33\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.417.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, juv_misd_count = 1, priors_count = (5.0, 10.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.50\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.93%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m10.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m90.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.90\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.4.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_other_count = 2\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 13.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.55%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m12.50%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m37.50%\u001b[39m and counterfactual cost = 3.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 12.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m62.50%\u001b[39m and counterfactual cost = 13.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.62\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.375.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0, juv_misd_count = 1, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 11.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.50\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m4.06%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m14.29%\u001b[39m and counterfactual cost = 11.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.14\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.357.\u001b[39m\n"
     ]
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset_cumulative(\n",
    "    rules_with_cumulative_correctness,\n",
    "    metric=\"total-correctness\",\n",
    "    sort_strategy=\"generic-sorting-ignore-forall-subgroups-empty\",\n",
    "    top_count=top_count,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        \"remove-fair-rules\",\n",
    "    ],\n",
    "    params=params\n",
    ")\n",
    "\n",
    "print_recourse_report_cumulative(\n",
    "    top_rules,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    show_then_costs=True,\n",
    "    correctness_metric=True,\n",
    "    metric_name = 'Equal Effectiveness'\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Fair Effectiveness-Cost Trade-Off"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m43.59%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m54.12%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m57.65%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m70.59%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m44.10%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m31.14%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m35.96%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m38.60%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.76.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m46.67%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m51.65%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m60.44%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.53%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m47.97%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m29.03%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m39.52%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m41.94%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.74.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m41.54%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m56.79%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m58.02%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m71.60%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m38.10%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m35.53%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m38.58%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m40.61%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.56.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m41.54%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m56.79%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m59.26%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.84%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m37.72%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m36.41%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m38.97%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m42.05%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.54.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m44.62%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m54.02%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m62.07%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m74.71%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m41.39%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m33.64%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m42.99%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m45.79%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.48.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m43.59%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m54.12%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m60.00%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.94%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m41.59%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m32.56%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m42.33%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m44.19%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.45.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m39.49%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m59.74%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m59.74%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m74.03%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m33.08%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m40.94%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m40.94%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m43.27%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.44.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_misd_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m43.08%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m54.76%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m58.33%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m70.24%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m36.36%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m37.23%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m40.96%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m40.96%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.43.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_misd_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m45.64%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m52.81%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m60.67%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m71.91%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m39.26%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m34.98%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m44.33%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m44.33%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.36.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_misd_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m41.03%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m57.50%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m58.75%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m71.25%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m33.46%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m39.88%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m42.20%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m42.20%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.33.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 0, juv_misd_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m41.03%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m57.50%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m60.00%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.50%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m32.50%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m41.67%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m43.45%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m43.45%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.32.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m41.54%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m56.79%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m61.73%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m75.31%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m36.36%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m37.23%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m45.21%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m47.34%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.29.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 0, juv_misd_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m38.97%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m60.53%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m60.53%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m73.68%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m29.98%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m44.52%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m44.52%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m44.52%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.26.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 0, juv_misd_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m43.59%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m55.29%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m62.35%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m74.12%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m35.20%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m39.01%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m47.25%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m47.25%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.22.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m42.56%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m55.42%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m60.24%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m72.29%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m36.17%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m36.90%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m45.45%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m45.45%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.21.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 0, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m40.51%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m58.23%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m62.03%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m74.68%\u001b[39m and counterfactual cost = 11.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m32.50%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m41.07%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m48.21%\u001b[39m and counterfactual cost = 10.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m48.21%\u001b[39m and counterfactual cost = 11.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.11.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m53.33%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m56.73%\u001b[39m and counterfactual cost = 10.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m55.90%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m36.33%\u001b[39m and counterfactual cost = 10.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.96.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m50.26%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m54.08%\u001b[39m and counterfactual cost = 10.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m51.45%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m33.08%\u001b[39m and counterfactual cost = 10.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.95.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m77.95%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m50.66%\u001b[39m and counterfactual cost = 1.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m80.66%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m34.53%\u001b[39m and counterfactual cost = 1.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.87.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m83.08%\u001b[39m covered out of 262\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m48.15%\u001b[39m and counterfactual cost = 1.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m86.46%\u001b[39m covered out of 483\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m32.66%\u001b[39m and counterfactual cost = 1.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.85.\u001b[39m\n"
     ]
    }
   ],
   "source": [
    "# taken from the other notebooks\n",
    "affected_pop_sizes = {\"African-American\": 483, \"Caucasian\": 262}\n",
    "\n",
    "top_rules,unfairness = facts.select_rules_subset_KStest(\n",
    "    rules_with_cumulative_correctness,\n",
    "    affected_pop_sizes,\n",
    "    top_count=top_count\n",
    ")\n",
    "\n",
    "print_recourse_report_KStest_cumulative(\n",
    "    top_rules,\n",
    "    population_sizes=affected_pop_sizes,\n",
    "    unfairness = unfairness,\n",
    "    show_then_costs=True,\n",
    "    metric_name = 'Fair Effectiveness-Cost Trade-Off'\n",
    "    # show_cumulative_plots=True\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Equal Effectiveness within Budget (Micro)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mjuv_other_count = 3\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 3.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.67\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.16%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness within Budget (Micro). Unfairness score = 0.667.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, juv_other_count = 1, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m3.08%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.67\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.93%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m20.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.20\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness within Budget (Micro). Unfairness score = 0.467.\u001b[39m\n",
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_other_count = 1\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.75\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.87%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m5.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m30.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.30\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness within Budget (Micro). Unfairness score = 0.45.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_fel_count = 0, juv_misd_count = 1, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.71%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m42.86%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.43\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness within Budget (Micro). Unfairness score = 0.429.\u001b[39m\n",
      "If \u001b[1mage_cat = 10-25, juv_other_count = 1, priors_count = (-0.1, 1.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m3.08%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.50\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.32%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.08\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness within Budget (Micro). Unfairness score = 0.417.\u001b[39m\n",
      "If \u001b[1mjuv_other_count = 1, priors_count = (-0.1, 1.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m3.08%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.50\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.32%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 1.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 2.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.08\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness within Budget (Micro). Unfairness score = 0.417.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, juv_misd_count = 1, priors_count = (5.0, 10.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.50\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.93%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m10.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m and counterfactual cost = 2.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m90.00%\u001b[39m and counterfactual cost = 3.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.90\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness within Budget (Micro). Unfairness score = 0.4.\u001b[39m\n"
     ]
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset_cumulative(\n",
    "    rules_with_cumulative_correctness,\n",
    "    metric=\"max-upto-cost\",\n",
    "    sort_strategy=\"generic-sorting-ignore-exists-subgroup-empty\",\n",
    "    top_count=top_count,\n",
    "    cost_threshold = cost_budget,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        \"remove-fair-rules\",\n",
    "        \"remove-above-thr-cost\"\n",
    "    ],\n",
    "    params=params\n",
    ")\n",
    "\n",
    "print_recourse_report_cumulative(\n",
    "    top_rules,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    show_then_costs=True,\n",
    "    correctness_metric = True,\n",
    "    metric_name = 'Equal Effectiveness within Budget (Micro)'\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Get ranking of subgroups based on metrics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "rules_with_both = {}\n",
    "for ifc, all_thens in rules_with_cumulative_correctness.items():\n",
    "    new_all_thens = {}\n",
    "    for sg, (cov, thens_cum) in all_thens.items():\n",
    "        thens_atom = rules_with_atomic_correctness[ifc][sg][1]\n",
    "        thens_atom_dict = {then: atom_cor for then, atom_cor in thens_atom}\n",
    "        new_all_thens[sg] = (cov, [(then, thens_atom_dict[then], cumcor) for then, cumcor, _cost in thens_cum])\n",
    "    rules_with_both[ifc] = new_all_thens"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "from facts.fairness_metrics_aggr import make_table, auto_budget_calculation\n",
    "budgets = auto_budget_calculation(rules_with_cumulative_correctness, cor_thres=0.5, percentiles=[0.3, 0.6, 0.9])\n",
    "\n",
    "df = make_table(\n",
    "    rules_with_both,\n",
    "    sensitive_attribute_vals=[\"Caucasian\", \"African-American\"],\n",
    "    effectiveness_thresholds=[0.3, 0.7],\n",
    "    cost_budgets=budgets,\n",
    "    params=params\n",
    ")\n",
    "\n",
    "df.drop(['weighted-average', 'mean-cost-cinf'], axis=1, inplace=True)\n",
    "df = df.loc[:, ~df.columns.duplicated()]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "#table of differences between Male and Female for each metric\n",
    "diff = get_diff_table(df, sensitive_attribute_vals=[\"Caucasian\", \"African-American\"], with_abs = True)\n",
    "diff = diff.set_index('subgroup')\n",
    "ranked = diff.drop(columns=[('Fair Effectiveness-Cost Trade-Off','bias')]).mask(diff == 0).rank(ascending = False,axis=0,method='dense')\n",
    "ranked = ranked.replace(np.nan,\"Fair\")\n",
    "\n",
    "rev_bias_metrics = ['Equal Effectiveness', 'Equal Effectiveness within Budget']\n",
    "comb_df = get_comb_df(df, ranked, diff, rev_bias_metrics, sensitive_attribute_vals=[\"Caucasian\",\"African-American\"])\n",
    "diff_real_val, _, = get_diff_real_diff_drop(df, diff, sensitive_attribute_vals=[\"Caucasian\", \"African-American\"])\n",
    "analysis_df,rank_analysis_df = get_analysis_dfs(comb_df, diff_real_val, rev_bias_metrics, ranked, sensitive_attribute_vals=[\"Caucasian\", \"African-American\"], percentage=0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"3\" halign=\"left\">(Equal Cost of Effectiveness(Macro), 0.3)</th>\n",
       "      <th colspan=\"3\" halign=\"left\">(Equal Cost of Effectiveness(Macro), 0.7)</th>\n",
       "      <th colspan=\"3\" halign=\"left\">(Equal Choice for Recourse, 0.3)</th>\n",
       "      <th>(Equal Choice for Recourse, 0.7)</th>\n",
       "      <th>...</th>\n",
       "      <th>(Equal Cost of Effectiveness(Micro), 0.3)</th>\n",
       "      <th colspan=\"3\" halign=\"left\">(Equal Cost of Effectiveness(Micro), 0.7)</th>\n",
       "      <th colspan=\"3\" halign=\"left\">Equal(Conditional) Mean Recourse</th>\n",
       "      <th colspan=\"3\" halign=\"left\">Fair Effectiveness-Cost Trade-Off</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>rank</th>\n",
       "      <th>score</th>\n",
       "      <th>bias against</th>\n",
       "      <th>rank</th>\n",
       "      <th>score</th>\n",
       "      <th>bias against</th>\n",
       "      <th>rank</th>\n",
       "      <th>score</th>\n",
       "      <th>bias against</th>\n",
       "      <th>rank</th>\n",
       "      <th>...</th>\n",
       "      <th>bias against</th>\n",
       "      <th>rank</th>\n",
       "      <th>score</th>\n",
       "      <th>bias against</th>\n",
       "      <th>rank</th>\n",
       "      <th>score</th>\n",
       "      <th>bias against</th>\n",
       "      <th>rank</th>\n",
       "      <th>score</th>\n",
       "      <th>bias against</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>subgroup</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>c_charge_degree = F</th>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>...</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>209.0</td>\n",
       "      <td>0.154860</td>\n",
       "      <td>African-American</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c_charge_degree = F, juv_fel_count = 0</th>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>...</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>262.0</td>\n",
       "      <td>0.123414</td>\n",
       "      <td>African-American</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c_charge_degree = F, juv_misd_count = 0</th>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>...</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>245.0</td>\n",
       "      <td>0.132559</td>\n",
       "      <td>African-American</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c_charge_degree = F, sex = Male</th>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>...</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>198.0</td>\n",
       "      <td>0.161255</td>\n",
       "      <td>African-American</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c_charge_degree = F, juv_fel_count = 0, juv_misd_count = 0</th>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>...</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>Fair</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Fair</td>\n",
       "      <td>296.0</td>\n",
       "      <td>0.107537</td>\n",
       "      <td>African-American</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 33 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                   (Equal Cost of Effectiveness(Macro), 0.3)  \\\n",
       "                                                                                        rank   \n",
       "subgroup                                                                                       \n",
       "c_charge_degree = F                                                                     Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0                                                  Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0                                                 Fair   \n",
       "c_charge_degree = F, sex = Male                                                         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...                                      Fair   \n",
       "\n",
       "                                                                       \\\n",
       "                                                   score bias against   \n",
       "subgroup                                                                \n",
       "c_charge_degree = F                                  0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0               0.0         Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0              0.0         Fair   \n",
       "c_charge_degree = F, sex = Male                      0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...   0.0         Fair   \n",
       "\n",
       "                                                   (Equal Cost of Effectiveness(Macro), 0.7)  \\\n",
       "                                                                                        rank   \n",
       "subgroup                                                                                       \n",
       "c_charge_degree = F                                                                     Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0                                                  Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0                                                 Fair   \n",
       "c_charge_degree = F, sex = Male                                                         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...                                      Fair   \n",
       "\n",
       "                                                                       \\\n",
       "                                                   score bias against   \n",
       "subgroup                                                                \n",
       "c_charge_degree = F                                  0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0               0.0         Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0              0.0         Fair   \n",
       "c_charge_degree = F, sex = Male                      0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...   0.0         Fair   \n",
       "\n",
       "                                                   (Equal Choice for Recourse, 0.3)  \\\n",
       "                                                                               rank   \n",
       "subgroup                                                                              \n",
       "c_charge_degree = F                                                            Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0                                         Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0                                        Fair   \n",
       "c_charge_degree = F, sex = Male                                                Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...                             Fair   \n",
       "\n",
       "                                                                       \\\n",
       "                                                   score bias against   \n",
       "subgroup                                                                \n",
       "c_charge_degree = F                                  0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0               0.0         Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0              0.0         Fair   \n",
       "c_charge_degree = F, sex = Male                      0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...   0.0         Fair   \n",
       "\n",
       "                                                   (Equal Choice for Recourse, 0.7)  \\\n",
       "                                                                               rank   \n",
       "subgroup                                                                              \n",
       "c_charge_degree = F                                                            Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0                                         Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0                                        Fair   \n",
       "c_charge_degree = F, sex = Male                                                Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...                             Fair   \n",
       "\n",
       "                                                    ...  \\\n",
       "                                                    ...   \n",
       "subgroup                                            ...   \n",
       "c_charge_degree = F                                 ...   \n",
       "c_charge_degree = F, juv_fel_count = 0              ...   \n",
       "c_charge_degree = F, juv_misd_count = 0             ...   \n",
       "c_charge_degree = F, sex = Male                     ...   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...  ...   \n",
       "\n",
       "                                                   (Equal Cost of Effectiveness(Micro), 0.3)  \\\n",
       "                                                                                bias against   \n",
       "subgroup                                                                                       \n",
       "c_charge_degree = F                                                                     Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0                                                  Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0                                                 Fair   \n",
       "c_charge_degree = F, sex = Male                                                         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...                                      Fair   \n",
       "\n",
       "                                                   (Equal Cost of Effectiveness(Micro), 0.7)  \\\n",
       "                                                                                        rank   \n",
       "subgroup                                                                                       \n",
       "c_charge_degree = F                                                                     Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0                                                  Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0                                                 Fair   \n",
       "c_charge_degree = F, sex = Male                                                         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...                                      Fair   \n",
       "\n",
       "                                                                       \\\n",
       "                                                   score bias against   \n",
       "subgroup                                                                \n",
       "c_charge_degree = F                                  0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0               0.0         Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0              0.0         Fair   \n",
       "c_charge_degree = F, sex = Male                      0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...   0.0         Fair   \n",
       "\n",
       "                                                   Equal(Conditional) Mean Recourse  \\\n",
       "                                                                               rank   \n",
       "subgroup                                                                              \n",
       "c_charge_degree = F                                                            Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0                                         Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0                                        Fair   \n",
       "c_charge_degree = F, sex = Male                                                Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...                             Fair   \n",
       "\n",
       "                                                                       \\\n",
       "                                                   score bias against   \n",
       "subgroup                                                                \n",
       "c_charge_degree = F                                  0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0               0.0         Fair   \n",
       "c_charge_degree = F, juv_misd_count = 0              0.0         Fair   \n",
       "c_charge_degree = F, sex = Male                      0.0         Fair   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...   0.0         Fair   \n",
       "\n",
       "                                                   Fair Effectiveness-Cost Trade-Off  \\\n",
       "                                                                                rank   \n",
       "subgroup                                                                               \n",
       "c_charge_degree = F                                                            209.0   \n",
       "c_charge_degree = F, juv_fel_count = 0                                         262.0   \n",
       "c_charge_degree = F, juv_misd_count = 0                                        245.0   \n",
       "c_charge_degree = F, sex = Male                                                198.0   \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...                             296.0   \n",
       "\n",
       "                                                                                \n",
       "                                                       score      bias against  \n",
       "subgroup                                                                        \n",
       "c_charge_degree = F                                 0.154860  African-American  \n",
       "c_charge_degree = F, juv_fel_count = 0              0.123414  African-American  \n",
       "c_charge_degree = F, juv_misd_count = 0             0.132559  African-American  \n",
       "c_charge_degree = F, sex = Male                     0.161255  African-American  \n",
       "c_charge_degree = F, juv_fel_count = 0, juv_mis...  0.107537  African-American  \n",
       "\n",
       "[5 rows x 33 columns]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "comb_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Rank = 1 Count</th>\n",
       "      <th>Caucasian bias against Count</th>\n",
       "      <th>African-American bias against Count</th>\n",
       "      <th>Top 10% Caucasian bias against Count</th>\n",
       "      <th>Top 10% African-American bias against Count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>(Equal Cost of Effectiveness(Macro), 0.3)</th>\n",
       "      <td>51</td>\n",
       "      <td>37</td>\n",
       "      <td>82</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Cost of Effectiveness(Macro), 0.7)</th>\n",
       "      <td>46</td>\n",
       "      <td>19</td>\n",
       "      <td>43</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Choice for Recourse, 0.3)</th>\n",
       "      <td>13</td>\n",
       "      <td>108</td>\n",
       "      <td>98</td>\n",
       "      <td>12</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Choice for Recourse, 0.7)</th>\n",
       "      <td>15</td>\n",
       "      <td>31</td>\n",
       "      <td>113</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Equal Effectiveness</th>\n",
       "      <td>1</td>\n",
       "      <td>99</td>\n",
       "      <td>416</td>\n",
       "      <td>14</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Effectiveness within Budget, 1.0)</th>\n",
       "      <td>4</td>\n",
       "      <td>97</td>\n",
       "      <td>365</td>\n",
       "      <td>16</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Effectiveness within Budget, 10.0)</th>\n",
       "      <td>1</td>\n",
       "      <td>117</td>\n",
       "      <td>474</td>\n",
       "      <td>20</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Cost of Effectiveness(Micro), 0.3)</th>\n",
       "      <td>51</td>\n",
       "      <td>37</td>\n",
       "      <td>82</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Cost of Effectiveness(Micro), 0.7)</th>\n",
       "      <td>46</td>\n",
       "      <td>19</td>\n",
       "      <td>43</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Equal(Conditional) Mean Recourse</th>\n",
       "      <td>37</td>\n",
       "      <td>130</td>\n",
       "      <td>303</td>\n",
       "      <td>19</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Fair Effectiveness-Cost Trade-Off, value)</th>\n",
       "      <td>5</td>\n",
       "      <td>398</td>\n",
       "      <td>597</td>\n",
       "      <td>18</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Count</th>\n",
       "      <td>270</td>\n",
       "      <td>1092</td>\n",
       "      <td>2616</td>\n",
       "      <td>107</td>\n",
       "      <td>240</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            Rank = 1 Count  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)               51   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)               46   \n",
       "(Equal Choice for Recourse, 0.3)                        13   \n",
       "(Equal Choice for Recourse, 0.7)                        15   \n",
       "Equal Effectiveness                                      1   \n",
       "(Equal Effectiveness within Budget, 1.0)                 4   \n",
       "(Equal Effectiveness within Budget, 10.0)                1   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)               51   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)               46   \n",
       "Equal(Conditional) Mean Recourse                        37   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)               5   \n",
       "Total Count                                            270   \n",
       "\n",
       "                                            Caucasian bias against Count  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                             37   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                             19   \n",
       "(Equal Choice for Recourse, 0.3)                                     108   \n",
       "(Equal Choice for Recourse, 0.7)                                      31   \n",
       "Equal Effectiveness                                                   99   \n",
       "(Equal Effectiveness within Budget, 1.0)                              97   \n",
       "(Equal Effectiveness within Budget, 10.0)                            117   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                             37   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                             19   \n",
       "Equal(Conditional) Mean Recourse                                     130   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                           398   \n",
       "Total Count                                                         1092   \n",
       "\n",
       "                                            African-American bias against Count  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                    82   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                    43   \n",
       "(Equal Choice for Recourse, 0.3)                                             98   \n",
       "(Equal Choice for Recourse, 0.7)                                            113   \n",
       "Equal Effectiveness                                                         416   \n",
       "(Equal Effectiveness within Budget, 1.0)                                    365   \n",
       "(Equal Effectiveness within Budget, 10.0)                                   474   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                    82   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                    43   \n",
       "Equal(Conditional) Mean Recourse                                            303   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                  597   \n",
       "Total Count                                                                2616   \n",
       "\n",
       "                                            Top 10% Caucasian bias against Count  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                      0   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                      0   \n",
       "(Equal Choice for Recourse, 0.3)                                              12   \n",
       "(Equal Choice for Recourse, 0.7)                                               8   \n",
       "Equal Effectiveness                                                           14   \n",
       "(Equal Effectiveness within Budget, 1.0)                                      16   \n",
       "(Equal Effectiveness within Budget, 10.0)                                     20   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                      0   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                      0   \n",
       "Equal(Conditional) Mean Recourse                                              19   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                    18   \n",
       "Total Count                                                                  107   \n",
       "\n",
       "                                            Top 10% African-American bias against Count  \n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                            11  \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                             6  \n",
       "(Equal Choice for Recourse, 0.3)                                                      8  \n",
       "(Equal Choice for Recourse, 0.7)                                                      6  \n",
       "Equal Effectiveness                                                                  37  \n",
       "(Equal Effectiveness within Budget, 1.0)                                             30  \n",
       "(Equal Effectiveness within Budget, 10.0)                                            39  \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                            11  \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                             6  \n",
       "Equal(Conditional) Mean Recourse                                                     24  \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                           62  \n",
       "Total Count                                                                         240  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analysis_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>(Equal Cost of Effectiveness(Macro), 0.3)</th>\n",
       "      <th>(Equal Cost of Effectiveness(Macro), 0.7)</th>\n",
       "      <th>(Equal Choice for Recourse, 0.3)</th>\n",
       "      <th>(Equal Choice for Recourse, 0.7)</th>\n",
       "      <th>Equal Effectiveness</th>\n",
       "      <th>(Equal Effectiveness within Budget, 1.0)</th>\n",
       "      <th>(Equal Effectiveness within Budget, 10.0)</th>\n",
       "      <th>(Equal Cost of Effectiveness(Micro), 0.3)</th>\n",
       "      <th>(Equal Cost of Effectiveness(Micro), 0.7)</th>\n",
       "      <th>Equal(Conditional) Mean Recourse</th>\n",
       "      <th>(Fair Effectiveness-Cost Trade-Off, value)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>(Equal Cost of Effectiveness(Macro), 0.3)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.650</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.169</td>\n",
       "      <td>0.801</td>\n",
       "      <td>0.398</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.796</td>\n",
       "      <td>0.226</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Cost of Effectiveness(Macro), 0.7)</th>\n",
       "      <td>0.96</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.925</td>\n",
       "      <td>0.625</td>\n",
       "      <td>0.127</td>\n",
       "      <td>0.518</td>\n",
       "      <td>0.236</td>\n",
       "      <td>0.96</td>\n",
       "      <td>0.20</td>\n",
       "      <td>0.518</td>\n",
       "      <td>0.149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Choice for Recourse, 0.3)</th>\n",
       "      <td>0.32</td>\n",
       "      <td>0.76</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.775</td>\n",
       "      <td>0.082</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.178</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.76</td>\n",
       "      <td>0.296</td>\n",
       "      <td>0.116</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Choice for Recourse, 0.7)</th>\n",
       "      <td>0.90</td>\n",
       "      <td>0.46</td>\n",
       "      <td>0.800</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.424</td>\n",
       "      <td>0.484</td>\n",
       "      <td>0.057</td>\n",
       "      <td>0.90</td>\n",
       "      <td>0.46</td>\n",
       "      <td>0.258</td>\n",
       "      <td>0.045</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Equal Effectiveness</th>\n",
       "      <td>0.20</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.750</td>\n",
       "      <td>1.000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.003</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.003</td>\n",
       "      <td>0.002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Effectiveness within Budget, 1.0)</th>\n",
       "      <td>0.80</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.750</td>\n",
       "      <td>0.750</td>\n",
       "      <td>1.000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.80</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.411</td>\n",
       "      <td>0.002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Effectiveness within Budget, 10.0)</th>\n",
       "      <td>0.20</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.750</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.003</td>\n",
       "      <td>1.000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.003</td>\n",
       "      <td>0.002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Cost of Effectiveness(Micro), 0.3)</th>\n",
       "      <td>0.20</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.650</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.169</td>\n",
       "      <td>0.801</td>\n",
       "      <td>0.398</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.796</td>\n",
       "      <td>0.226</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Equal Cost of Effectiveness(Micro), 0.7)</th>\n",
       "      <td>0.96</td>\n",
       "      <td>0.20</td>\n",
       "      <td>0.925</td>\n",
       "      <td>0.625</td>\n",
       "      <td>0.127</td>\n",
       "      <td>0.518</td>\n",
       "      <td>0.236</td>\n",
       "      <td>0.96</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.518</td>\n",
       "      <td>0.149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Equal(Conditional) Mean Recourse</th>\n",
       "      <td>0.98</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.507</td>\n",
       "      <td>0.772</td>\n",
       "      <td>0.512</td>\n",
       "      <td>0.98</td>\n",
       "      <td>1.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.627</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>(Fair Effectiveness-Cost Trade-Off, value)</th>\n",
       "      <td>0.68</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.750</td>\n",
       "      <td>0.800</td>\n",
       "      <td>0.801</td>\n",
       "      <td>0.202</td>\n",
       "      <td>0.801</td>\n",
       "      <td>0.68</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.330</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            (Equal Cost of Effectiveness(Macro), 0.3)  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                         NaN   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                        0.96   \n",
       "(Equal Choice for Recourse, 0.3)                                                 0.32   \n",
       "(Equal Choice for Recourse, 0.7)                                                 0.90   \n",
       "Equal Effectiveness                                                              0.20   \n",
       "(Equal Effectiveness within Budget, 1.0)                                         0.80   \n",
       "(Equal Effectiveness within Budget, 10.0)                                        0.20   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                        0.20   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                        0.96   \n",
       "Equal(Conditional) Mean Recourse                                                 0.98   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                       0.68   \n",
       "\n",
       "                                            (Equal Cost of Effectiveness(Macro), 0.7)  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                        1.00   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                         NaN   \n",
       "(Equal Choice for Recourse, 0.3)                                                 0.76   \n",
       "(Equal Choice for Recourse, 0.7)                                                 0.46   \n",
       "Equal Effectiveness                                                              1.00   \n",
       "(Equal Effectiveness within Budget, 1.0)                                         1.00   \n",
       "(Equal Effectiveness within Budget, 10.0)                                        1.00   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                        1.00   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                        0.20   \n",
       "Equal(Conditional) Mean Recourse                                                 1.00   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                       1.00   \n",
       "\n",
       "                                            (Equal Choice for Recourse, 0.3)  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                              0.650   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                              0.925   \n",
       "(Equal Choice for Recourse, 0.3)                                         NaN   \n",
       "(Equal Choice for Recourse, 0.7)                                       0.800   \n",
       "Equal Effectiveness                                                    0.750   \n",
       "(Equal Effectiveness within Budget, 1.0)                               0.750   \n",
       "(Equal Effectiveness within Budget, 10.0)                              0.750   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                              0.650   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                              0.925   \n",
       "Equal(Conditional) Mean Recourse                                       1.000   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                             0.750   \n",
       "\n",
       "                                            (Equal Choice for Recourse, 0.7)  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                              1.000   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                              0.625   \n",
       "(Equal Choice for Recourse, 0.3)                                       0.775   \n",
       "(Equal Choice for Recourse, 0.7)                                         NaN   \n",
       "Equal Effectiveness                                                    1.000   \n",
       "(Equal Effectiveness within Budget, 1.0)                               0.750   \n",
       "(Equal Effectiveness within Budget, 10.0)                              1.000   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                              1.000   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                              0.625   \n",
       "Equal(Conditional) Mean Recourse                                       1.000   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                             0.800   \n",
       "\n",
       "                                            Equal Effectiveness  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                 0.169   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                 0.127   \n",
       "(Equal Choice for Recourse, 0.3)                          0.082   \n",
       "(Equal Choice for Recourse, 0.7)                          0.424   \n",
       "Equal Effectiveness                                         NaN   \n",
       "(Equal Effectiveness within Budget, 1.0)                  1.000   \n",
       "(Equal Effectiveness within Budget, 10.0)                 0.003   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                 0.169   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                 0.127   \n",
       "Equal(Conditional) Mean Recourse                          0.507   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                0.801   \n",
       "\n",
       "                                            (Equal Effectiveness within Budget, 1.0)  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                      0.801   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                      0.518   \n",
       "(Equal Choice for Recourse, 0.3)                                               1.000   \n",
       "(Equal Choice for Recourse, 0.7)                                               0.484   \n",
       "Equal Effectiveness                                                            1.000   \n",
       "(Equal Effectiveness within Budget, 1.0)                                         NaN   \n",
       "(Equal Effectiveness within Budget, 10.0)                                      1.000   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                      0.801   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                      0.518   \n",
       "Equal(Conditional) Mean Recourse                                               0.772   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                     0.202   \n",
       "\n",
       "                                            (Equal Effectiveness within Budget, 10.0)  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                       0.398   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                       0.236   \n",
       "(Equal Choice for Recourse, 0.3)                                                0.178   \n",
       "(Equal Choice for Recourse, 0.7)                                                0.057   \n",
       "Equal Effectiveness                                                             0.003   \n",
       "(Equal Effectiveness within Budget, 1.0)                                        1.000   \n",
       "(Equal Effectiveness within Budget, 10.0)                                         NaN   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                       0.398   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                       0.236   \n",
       "Equal(Conditional) Mean Recourse                                                0.512   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                      0.801   \n",
       "\n",
       "                                            (Equal Cost of Effectiveness(Micro), 0.3)  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                        0.20   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                        0.96   \n",
       "(Equal Choice for Recourse, 0.3)                                                 0.32   \n",
       "(Equal Choice for Recourse, 0.7)                                                 0.90   \n",
       "Equal Effectiveness                                                              0.20   \n",
       "(Equal Effectiveness within Budget, 1.0)                                         0.80   \n",
       "(Equal Effectiveness within Budget, 10.0)                                        0.20   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                         NaN   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                        0.96   \n",
       "Equal(Conditional) Mean Recourse                                                 0.98   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                       0.68   \n",
       "\n",
       "                                            (Equal Cost of Effectiveness(Micro), 0.7)  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                        1.00   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                        0.20   \n",
       "(Equal Choice for Recourse, 0.3)                                                 0.76   \n",
       "(Equal Choice for Recourse, 0.7)                                                 0.46   \n",
       "Equal Effectiveness                                                              1.00   \n",
       "(Equal Effectiveness within Budget, 1.0)                                         1.00   \n",
       "(Equal Effectiveness within Budget, 10.0)                                        1.00   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                        1.00   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                         NaN   \n",
       "Equal(Conditional) Mean Recourse                                                 1.00   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                       1.00   \n",
       "\n",
       "                                            Equal(Conditional) Mean Recourse  \\\n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                              0.796   \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                              0.518   \n",
       "(Equal Choice for Recourse, 0.3)                                       0.296   \n",
       "(Equal Choice for Recourse, 0.7)                                       0.258   \n",
       "Equal Effectiveness                                                    0.003   \n",
       "(Equal Effectiveness within Budget, 1.0)                               0.411   \n",
       "(Equal Effectiveness within Budget, 10.0)                              0.003   \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                              0.796   \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                              0.518   \n",
       "Equal(Conditional) Mean Recourse                                         NaN   \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                             0.330   \n",
       "\n",
       "                                            (Fair Effectiveness-Cost Trade-Off, value)  \n",
       "(Equal Cost of Effectiveness(Macro), 0.3)                                        0.226  \n",
       "(Equal Cost of Effectiveness(Macro), 0.7)                                        0.149  \n",
       "(Equal Choice for Recourse, 0.3)                                                 0.116  \n",
       "(Equal Choice for Recourse, 0.7)                                                 0.045  \n",
       "Equal Effectiveness                                                              0.002  \n",
       "(Equal Effectiveness within Budget, 1.0)                                         0.002  \n",
       "(Equal Effectiveness within Budget, 10.0)                                        0.002  \n",
       "(Equal Cost of Effectiveness(Micro), 0.3)                                        0.226  \n",
       "(Equal Cost of Effectiveness(Micro), 0.7)                                        0.149  \n",
       "Equal(Conditional) Mean Recourse                                                 0.627  \n",
       "(Fair Effectiveness-Cost Trade-Off, value)                                         NaN  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "max_ranks = get_map_metric_to_max_rank(ranked)\n",
    "rank_divided = get_other_ranks_divided(rank_analysis_df, max_ranks)\n",
    "rank_divided"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
