{
 "cells": [
  {
   "attachments": {},
   "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": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from pprint import pprint\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import classification_report, confusion_matrix, ConfusionMatrixDisplay\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",
    "import matplotlib.pyplot as plt\n",
    "from aif360.sklearn.datasets import fetch_compas\n",
    "from facts.utils import load_rules_by_if, save_rules_by_if\n",
    "\n",
    "from IPython.display import Markdown, display"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load Dataset"
   ]
  },
  {
   "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": {
    "tags": []
   },
   "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>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>1</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>2</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",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Female</td>\n",
       "      <td>25 - 45</td>\n",
       "      <td>Caucasian</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>(-0.1, 1.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  25 - 45  African-American              0               0   \n",
       "1    Male    10-25  African-American              0               0   \n",
       "2    Male  25 - 45         Caucasian              0               0   \n",
       "3  Female  25 - 45         Caucasian              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                1    (1.0, 5.0]               F  \n",
       "2                0  (10.0, 15.0]               F  \n",
       "3                0   (-0.1, 1.0]               M  \n",
       "4                0   (-0.1, 1.0]               F  "
      ]
     },
     "execution_count": 3,
     "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()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Model training and test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "num_features = X._get_numeric_data().columns.to_list()\n",
    "cate_features = X.select_dtypes(include=['object','category']).columns.to_list()\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.7, random_state=131313, stratify=y)\n",
    "\n",
    "X_train = X_train.reset_index(drop=True)\n",
    "X_test = X_test.reset_index(drop=True)\n",
    "y_train = y_train.reset_index(drop=True)\n",
    "y_test = y_test.reset_index(drop=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 96.5 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([1., 0., 1., 1., 1., 0., 0., 0., 0., 1., 0., 1., 0., 1., 1., 0., 0.,\n",
       "       0., 0., 0., 1., 1., 0., 1., 1., 0., 0., 0., 1., 1., 1., 1., 0., 0.,\n",
       "       0., 0., 0., 1., 1., 0., 0., 1., 1., 1., 0., 1., 0., 1., 0., 0., 0.,\n",
       "       0., 0., 0., 0., 0., 1., 0., 0., 1., 1., 1., 0., 0., 1., 1., 0., 1.,\n",
       "       1., 1., 1., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0., 1., 0., 1., 1.,\n",
       "       1., 0., 1., 0., 0., 1., 1., 1., 1., 1., 1., 0., 1., 0., 1.])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "\n",
    "model = customLogisticRegression(max_iter = 1500)\n",
    "model.fit(X_train, y_train, cate_columns=cate_features, target_column='target')\n",
    "model.predict(X_test.iloc[:100, :])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.65      0.65      0.65       745\n",
      "           1       0.69      0.69      0.69       837\n",
      "\n",
      "    accuracy                           0.67      1582\n",
      "   macro avg       0.67      0.67      0.67      1582\n",
      "weighted avg       0.67      0.67      0.67      1582\n",
      "\n"
     ]
    }
   ],
   "source": [
    "positive_label = 1\n",
    "negative_label = 0\n",
    "preds_Xtest = model.predict(X_test)\n",
    "print(classification_report(y_test.map({negative_label: 0, positive_label: 1}), preds_Xtest))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19784 characters]",
      "text/plain": [
       "<Figure size 640x480 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "conf_matrix = confusion_matrix(y_test, preds_Xtest)\n",
    "cm_disp = ConfusionMatrixDisplay(confusion_matrix=conf_matrix)\n",
    "cm_disp.plot()\n",
    "plt.show()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Main Contribution"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Find all valid if-thens with all respective coverages and correctness, for all subgroups.\n",
    "\n",
    "**Caution!** This step takes time. Uncomment the following block if you wish to run."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# #Uncomment if you want to find new rules with different support\n",
    "\n",
    "# ifthens_coverage_correctness = valid_ifthens_with_coverage_correctness(\n",
    "#     X_test,\n",
    "#     model=model,\n",
    "#     sensitive_attribute='race',\n",
    "#     freqitem_minsupp = 0.01,\n",
    "#     missing_subgroup_val=\"Unknown\",\n",
    "#     drop_infeasible = True,\n",
    "#     drop_above = False\n",
    "# )\n",
    "\n",
    "# print(f\"Number of if-thens: {len(ifthens_coverage_correctness)}\")\n",
    "# rules_by_if = rules2rulesbyif(ifthens_coverage_correctness)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from facts.utils import load_rules_by_if, save_rules_by_if\n",
    "\n",
    "## Use this for loading rules from disk\n",
    "rules_by_if = load_rules_by_if(computed_rules_file)\n",
    "\n",
    "## Use this for saving rules on disk\n",
    "#save_rules_by_if(precomputed_rules_file, rules_by_if)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\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 correctness \u001b[32m50.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_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m50.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.71%\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 correctness \u001b[32m85.71%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m42.86%\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 correctness \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[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m92.86%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m42.86%\u001b[39m.\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, 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[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\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 correctness \u001b[32m50.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_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m50.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.09%\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 correctness \u001b[32m75.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m37.50%\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 correctness \u001b[32m81.25%\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 correctness \u001b[32m87.50%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m37.50%\u001b[39m.\n",
      "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 correctness \u001b[32m66.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 correctness \u001b[32m0.00%\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[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\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 correctness \u001b[32m0.00%\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 correctness \u001b[32m50.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_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m50.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.90%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m46.67%\u001b[39m.\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 correctness \u001b[32m86.67%\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 correctness \u001b[32m93.33%\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 correctness \u001b[32m93.33%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m40.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = M, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m4.62%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with correctness \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[0m with correctness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.74%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m44.44%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with correctness \u001b[32m88.89%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "If \u001b[1mage_cat = 10-25, c_charge_degree = M, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m4.10%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with correctness \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[0m with correctness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.35%\u001b[39m covered\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m42.86%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with correctness \u001b[32m85.71%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m, \u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m100.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "If \u001b[1mc_charge_degree = M, juv_misd_count = 0, priors_count = (1.0, 5.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m6.15%\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 correctness \u001b[32m8.33%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with correctness \u001b[32m75.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m0.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 = F\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with correctness \u001b[32m50.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with correctness \u001b[32m87.50%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = F\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "If \u001b[1mjuv_misd_count = 0, 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 correctness \u001b[32m50.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with correctness \u001b[32m0.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 correctness \u001b[32m8.33%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\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 correctness \u001b[32m50.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with correctness \u001b[32m0.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 correctness \u001b[32m8.33%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (1.0, 5.0]\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\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\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\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 correctness \u001b[32m0.00%\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 correctness \u001b[32m50.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_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m50.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.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[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m41.18%\u001b[39m.\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 correctness \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 correctness \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 correctness \u001b[32m88.24%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m35.29%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with correctness \u001b[32m0.00%\u001b[39m.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "K = 10\n",
    "\n",
    "# keep K ifs with maximum coverage on Females\n",
    "# TODO: the below is currently dataset dependent\n",
    "# rules_by_if_filtered = sorted(rules_by_if.items(), key=lambda e: e[1][\"F\"][0][1], reverse=True)[:K]\n",
    "\n",
    "# keep K ifs with maximum absolute difference in correctness between Males and Females.\n",
    "# TODO: the below is currently dataset dependent\n",
    "rules_by_if_filtered = sorted(rules_by_if.items(), key=lambda e: abs(e[1][\"Caucasian\"][1][0][1]-e[1][\"African-American\"][1][0][1]), reverse=True)[:K]\n",
    "\n",
    "rules_by_if_filtered = dict(rules_by_if_filtered)\n",
    "\n",
    "print(recourse_report_reverse(rules_by_if_filtered))"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Macro Viewpoint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "tags": []
   },
   "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)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Equal Cost of Effectiveness (Macro)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_misd_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m79.49%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m50.32%\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[34m72.53%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m50.66%\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[34m80.66%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, juv_misd_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m76.92%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m52.00%\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[34m65.18%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m75.38%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m52.38%\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[34m70.02%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_misd_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m74.87%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m52.74%\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[34m67.89%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m73.85%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m53.47%\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[34m72.92%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, juv_misd_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m72.31%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m54.61%\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[34m60.74%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m71.28%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m55.40%\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[34m63.44%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m71.28%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m55.40%\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[34m64.99%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "If \u001b[1mc_charge_degree = F, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m70.77%\u001b[39m covered out of 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m55.80%\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[34m67.70%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35minf\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = inf.\u001b[39m\n",
      "\n"
     ]
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset(\n",
    "    rules_by_if,\n",
    "    metric=\"min-above-thr\",\n",
    "    sort_strategy=\"abs-diff-decr-ignore-forall-subgroups-empty\",\n",
    "    top_count=10,\n",
    "    cor_threshold=0.5,\n",
    "    filter_sequence=[\"remove-below-thr\", \"remove-fair-rules\"],\n",
    ")\n",
    "\n",
    "pop_sizes = {sg: (X[\"race\"] == sg).sum() for sg in X[\"race\"].unique()}\n",
    "print(recourse_report_reverse(\n",
    "    top_rules,\n",
    "    population_sizes = pop_sizes,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True\n",
    "))"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Equal Choice for Recourse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m51.65%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m60.44%\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 correctness \u001b[32m72.53%\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[34m47.97%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m52.81%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m60.67%\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 correctness \u001b[32m71.91%\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[34m39.26%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m54.02%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m62.07%\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 correctness \u001b[32m74.71%\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[34m41.39%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m55.29%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m62.35%\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 correctness \u001b[32m74.12%\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[34m35.20%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m54.12%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m60.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 correctness \u001b[32m72.94%\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[34m41.59%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\u001b[39m\n",
      "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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m54.12%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m57.65%\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 correctness \u001b[32m70.59%\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[34m44.10%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m54.76%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m58.33%\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 correctness \u001b[32m70.24%\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[34m36.36%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m55.42%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m60.24%\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 correctness \u001b[32m72.29%\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[34m36.17%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m56.79%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m58.02%\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 correctness \u001b[32m71.60%\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[34m38.10%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\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 2100\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with correctness \u001b[32m56.79%\u001b[39m.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with correctness \u001b[32m59.26%\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 correctness \u001b[32m72.84%\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[34m37.72%\u001b[39m covered out of 3173\n",
      "\t\t\u001b[31mNo recourses for this subgroup!\n",
      "\u001b[39m\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.00\u001b[39m\n",
      "\t\u001b[35mBias against African-American. Unfairness score = 3.\u001b[39m\n",
      "\n"
     ]
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset(\n",
    "    rules_by_if,\n",
    "    metric=\"num-above-thr\",\n",
    "    sort_strategy=\"abs-diff-decr-ignore-forall-subgroups-empty\",\n",
    "    top_count=10,\n",
    "    cor_threshold=0.5,\n",
    "    filter_sequence=[\"remove-below-thr\"]\n",
    ")\n",
    "\n",
    "pop_sizes = {sg: (X[\"race\"] == sg).sum() for sg in X[\"race\"].unique()}\n",
    "print(recourse_report_reverse(\n",
    "    top_rules,\n",
    "    population_sizes = pop_sizes,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True\n",
    "))"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Micro viewpoint"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We start by computing the cumulative effectiveness of the actions for each subgroup and each value of the protected attribute.\n",
    "\n",
    "**Caution!** This step takes time. Uncomment the following block if you wish to run."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# rules_with_cumulative = facts.cum_corr_costs_all(rules_by_if, X_test, model, sensitive_attribute=\"race\", params=params)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "## Use this for loading rules from disk\n",
    "rules_with_cumulative = load_rules_by_if(computed_rules_with_cumulative_file)\n",
    "\n",
    "## Use this for saving rules on disk\n",
    "# save_rules_by_if(computed_rules_with_cumulative_file, rules_with_cumulative)\n",
    "\n",
    "# facts.update_costs_cumulative(rules_with_cumulative, params)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Equal (Conditional) Mean Recourse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.29.\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 = 10.29.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.29\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.55%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m12.50%\u001b[39m and counterfactual cost = 0.29.\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 = 10.29.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m7.79\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 7.5.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28404 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.14.\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 = 10.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.87%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m20.00%\u001b[39m and counterfactual cost = 0.14.\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 = 10.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m4.43\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 5.714.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26024 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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 = 1.14.\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 = 10.14.\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 = 10.14.\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 = 11.14.\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 = 11.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m4.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.93%\u001b[39m covered out of 569\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 = 1.14.\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 = 10.14.\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 = 10.14.\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 = 11.14.\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 = 11.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m8.34\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 4.2.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27512 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, juv_misd_count = 0, 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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.14.\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 = 10.14.\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 = 10.14.\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 = 11.14.\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 = 11.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m5.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.32%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 0.14.\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 = 10.14.\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 = 10.14.\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 = 11.14.\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 = 11.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m9.31\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 4.167.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24324 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset_cumulative(\n",
    "    rules_with_cumulative,\n",
    "    metric=\"fairness-of-mean-recourse-conditional\",\n",
    "    sort_strategy=\"generic-sorting-ignore-exists-subgroup-empty\",\n",
    "    top_count=10,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        # \"remove-fair-rules\"\n",
    "    ],\n",
    "    params=params\n",
    ")\n",
    "\n",
    "pop_sizes = {sg: ((X_test[\"race\"] == sg) & (preds_Xtest == 0)).sum() for sg in X_test[\"race\"].unique()}\n",
    "print_recourse_report_cumulative(\n",
    "    top_rules,\n",
    "    population_sizes=pop_sizes,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    show_then_costs=True,\n",
    "    show_cumulative_plots=True,\n",
    "    correctness_metric=False\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Equal Effectiveness"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 0.43.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.43.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25124 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.08.\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 = 1.08.\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 = 10.08.\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 = 10.08.\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 = 11.08.\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 = 11.08.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.08.\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 = 1.08.\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 = 10.08.\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 = 10.08.\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 = 11.08.\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 = 11.08.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25792 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 23912 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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 = 10.14.\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 = 11.14.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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 = 10.14.\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 = 11.14.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26224 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 0.14.\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 = 10.14.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m15.15%\u001b[39m and counterfactual cost = 0.14.\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 = 10.14.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24884 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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 = 1.08.\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 = 1.08.\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 = 2.08.\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 = 2.08.\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 out of 569\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 = 1.08.\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 = 1.08.\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 = 2.08.\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 = 2.08.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25140 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.29.\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 = 1.29.\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 = 10.29.\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 = 11.29.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m12.50%\u001b[39m and counterfactual cost = 0.29.\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 = 1.29.\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 = 10.29.\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 = 11.29.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24988 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.08.\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 = 10.08.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.08.\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 = 10.08.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24552 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, juv_fel_count = 1, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.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 = 1.1.\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 = 10.1.\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 = 11.1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.25\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.90%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.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[32m40.00%\u001b[39m and counterfactual cost = 1.1.\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[32m46.67%\u001b[39m and counterfactual cost = 10.1.\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[32m60.00%\u001b[39m and counterfactual cost = 11.1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.60\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.35.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26344 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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.0.\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.0.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.333.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27908 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, c_charge_degree = F, 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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.08.\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 = 1.08.\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 = 10.08.\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 = 11.08.\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[34m3.29%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.08.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m5.88%\u001b[39m and counterfactual cost = 1.08.\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[32m17.65%\u001b[39m and counterfactual cost = 10.08.\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[32m17.65%\u001b[39m and counterfactual cost = 11.08.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.18\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.324.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25632 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, juv_misd_count = 2\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.15.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 10.15.\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[32m75.00%\u001b[39m and counterfactual cost = 10.15.\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[34m1.35%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.15.\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 = 10.15.\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[32m42.86%\u001b[39m and counterfactual cost = 10.15.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.43\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.321.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26484 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "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 171\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.0.\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.0.\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.0.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.71\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m44.10%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.39\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.32.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29392 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 1, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m2.05%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.1.\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 = 10.1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.25\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.74%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_fel_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.1.\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[32m55.56%\u001b[39m and counterfactual cost = 10.1.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.56\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.306.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24464 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset_cumulative(\n",
    "    rules_with_cumulative,\n",
    "    metric=\"total-correctness\",\n",
    "    sort_strategy=\"generic-sorting-ignore-forall-subgroups-empty\",\n",
    "    top_count=50,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        # \"remove-fair-rules\",\n",
    "        # \"keep-only-min-change\"\n",
    "    ],\n",
    "    params=params\n",
    ")\n",
    "\n",
    "pop_sizes = {sg: ((X_test[\"race\"] == sg) & (preds_Xtest == 0)).sum() for sg in X_test[\"race\"].unique()}\n",
    "print_recourse_report_cumulative(\n",
    "    top_rules,\n",
    "    population_sizes=pop_sizes,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    show_then_costs=True,\n",
    "    show_cumulative_plots=True,\n",
    "    correctness_metric= True\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Equal Cost of Effectiveness (micro)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, juv_misd_count = 0, juv_other_count = 1, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m5.13%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m30.00%\u001b[39m and counterfactual cost = 0.14.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m70.00%\u001b[39m and counterfactual cost = 10.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.87%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m5.00%\u001b[39m and counterfactual cost = 0.14.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m60.00%\u001b[39m and counterfactual cost = 10.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.14\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 10.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25344 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, juv_other_count = 1, priors_count = (-0.1, 1.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m3.08%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.51%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m15.38%\u001b[39m and counterfactual cost = 0.14.\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 = 10.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.14\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 10.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 23640 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, priors_count = (5.0, 10.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m3.08%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m33.33%\u001b[39m and counterfactual cost = 1.0.\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[34m2.90%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m20.00%\u001b[39m and counterfactual cost = 1.0.\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[32m20.00%\u001b[39m and counterfactual cost = 11.0.\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[32m86.67%\u001b[39m and counterfactual cost = 11.0.\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 Effectiveness. Unfairness score = 10.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25840 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.29.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.29\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.55%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m12.50%\u001b[39m and counterfactual cost = 0.29.\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 = 10.29.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.29\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 10.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28244 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.68%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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 = 10.14.\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 = 11.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m11.14\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 10.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26520 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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[34m47.97%\u001b[39m covered out of 569\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.0.\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.0.\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 Effectiveness. Unfairness score = 9.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24768 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m14.36%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m46.43%\u001b[39m and counterfactual cost = 1.0.\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[34m11.41%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m27.12%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m27.12%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m88.14%\u001b[39m and counterfactual cost = 10.0.\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 Effectiveness. Unfairness score = 9.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25300 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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 = 1.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.93%\u001b[39m covered out of 569\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 = 1.14.\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 = 10.14.\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 = 10.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.14\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 9.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26516 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.08.\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 = 1.08.\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 = 10.08.\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 = 10.08.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m10.08\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m3.29%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.08.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_misd_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m35.29%\u001b[39m and counterfactual cost = 1.08.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.08\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 9.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25032 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_fel_count = 0, juv_other_count = 0, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m5.13%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m30.00%\u001b[39m and counterfactual cost = 1.0.\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 and counterfactual cost = 2.0.\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[34m6.00%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m29.03%\u001b[39m and counterfactual cost = 1.0.\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 and counterfactual cost = 2.0.\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 Effectiveness. Unfairness score = 1.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26420 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mjuv_misd_count = 0, 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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m16.67%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m2.71%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m35.71%\u001b[39m and counterfactual cost = 0.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.14\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 1.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 23948 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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.0.\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[34m2.51%\u001b[39m covered out of 569\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.0.\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.0.\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 Effectiveness. Unfairness score = 1.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24788 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, c_charge_degree = F, juv_other_count = 1, priors_count = (1.0, 5.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.54%\u001b[39m covered out of 171\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[32m33.33%\u001b[39m and counterfactual cost = 1.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.14\u001b[39m\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m1.55%\u001b[39m covered out of 569\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[32m0.00%\u001b[39m and counterfactual cost = 1.14.\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m, \u001b[31mjuv_other_count = 0\u001b[39m, \u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m75.00%\u001b[39m and counterfactual cost = 2.14.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m2.14\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 1.0.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25816 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset_cumulative(\n",
    "    rules_with_cumulative,\n",
    "    metric=\"min-above-corr\",\n",
    "    sort_strategy=\"generic-sorting-ignore-exists-subgroup-empty\",\n",
    "    top_count=50,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        \"remove-fair-rules\",\n",
    "        \"keep-cheap-rules-above-thr-cor\",\n",
    "        # \"keep-only-min-change\",\n",
    "        \n",
    "    ],\n",
    "    cor_threshold = 0.3,\n",
    "    params=params\n",
    ")\n",
    "\n",
    "pop_sizes = {sg: ((X_test[\"race\"] == sg) & (preds_Xtest == 0)).sum() for sg in X_test[\"race\"].unique()}\n",
    "print_recourse_report_cumulative(\n",
    "    top_rules,\n",
    "    population_sizes=pop_sizes,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    show_then_costs=True,\n",
    "    show_cumulative_plots=True,\n",
    "    correctness_metric=False\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Equal Effectiveness Within Budget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m66.67%\u001b[39m and counterfactual cost = 0.43.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 0.43.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25124 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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 = 1.14.\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 out of 569\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 = 1.14.\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. Unfairness score = 0.467.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24288 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m25.00%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m5.00%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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. Unfairness score = 0.45.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25652 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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 = 1.08.\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 out of 569\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 = 1.08.\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. Unfairness score = 0.429.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 23604 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.14.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 0.14.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24224 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m8.33%\u001b[39m and counterfactual cost = 0.14.\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 = 1.14.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 23912 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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 = 1.08.\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 = 1.08.\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 = 2.08.\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 = 2.08.\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 out of 569\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 = 1.08.\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 = 1.08.\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 = 2.08.\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 = 2.08.\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",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25140 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "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 out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 0.29.\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.55%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mjuv_other_count = 0\u001b[39m\u001b[0m with effectiveness \u001b[32m12.50%\u001b[39m and counterfactual cost = 0.29.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.12\u001b[39m\n",
      "\t\u001b[35mBias against African-American due to Equal Effectiveness. Unfairness score = 0.375.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28664 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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.0.\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.0.\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.0.\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.55%\u001b[39m covered out of 569\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.0.\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.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.333.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24900 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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.0.\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.0.\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 out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m80.00%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m1.00\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.333.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27908 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mjuv_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 out of 171\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 = 1.08.\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 = 1.08.\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.71%\u001b[39m covered out of 569\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[32m21.43%\u001b[39m and counterfactual cost = 1.08.\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[32m78.57%\u001b[39m and counterfactual cost = 1.08.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.79\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.286.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27316 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, juv_misd_count = 0, juv_other_count = 0, priors_count = (5.0, 10.0]\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m1.03%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m0.00%\u001b[39m and counterfactual cost = 1.0.\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.35%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m28.57%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\t\u001b[1mAggregate cost\u001b[0m of the above recourses = \u001b[35m0.29\u001b[39m\n",
      "\t\u001b[35mBias against Caucasian due to Equal Effectiveness. Unfairness score = 0.286.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26564 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "top_rules, subgroup_costs = facts.select_rules_subset_cumulative(\n",
    "    rules_with_cumulative,\n",
    "    metric=\"max-upto-cost\",\n",
    "    sort_strategy=\"generic-sorting-ignore-exists-subgroup-empty\",\n",
    "    top_count=50,\n",
    "    filter_sequence = [\n",
    "        \"remove-contained\",\n",
    "        \"remove-fair-rules\",\n",
    "        \"remove-above-thr-cost\"\n",
    "        #\"remove-below-thr\",\n",
    "        #\"keep-only-min-change\",\n",
    "        \n",
    "    ],\n",
    "    cost_threshold = 10,\n",
    "    params=params\n",
    ")\n",
    "\n",
    "pop_sizes = {sg: ((X_test[\"race\"] == sg) & (preds_Xtest == 0)).sum() for sg in X_test[\"race\"].unique()}\n",
    "print_recourse_report_cumulative(\n",
    "    top_rules,\n",
    "    population_sizes=pop_sizes,\n",
    "    subgroup_costs=subgroup_costs,\n",
    "    show_subgroup_costs=True,\n",
    "    show_then_costs=True,\n",
    "    show_cumulative_plots=True,\n",
    "    correctness_metric = True\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Fair Effectiveness-Cost Trade-Off"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m44.10%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.43.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29392 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m47.97%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.4.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24548 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m38.10%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.27.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28428 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m37.72%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.25.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28472 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m41.39%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.2.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 23896 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m33.08%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.17.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27844 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m41.59%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.16.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28440 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m36.36%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.16.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27276 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m39.26%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.1.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28356 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m33.46%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.08.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27324 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m32.50%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.07.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26428 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m36.36%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.03.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28340 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m29.98%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 2.02.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26852 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m35.20%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.98.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28304 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m36.17%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.97.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27352 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\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.0.\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m32.50%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.88.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28160 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m53.33%\u001b[39m covered out of 171\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m55.90%\u001b[39m covered out of 569\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.72.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 30724 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m51.45%\u001b[39m covered out of 569\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.71.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25132 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 171\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m80.66%\u001b[39m covered out of 569\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.64.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28788 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m83.08%\u001b[39m covered out of 171\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m86.46%\u001b[39m covered out of 569\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.63.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28808 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m47.69%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m55.91%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m44.10%\u001b[39m covered out of 569\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.57.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 30884 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m50.77%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m58.59%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m48.16%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m39.36%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.56.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29608 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m73.85%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m53.47%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m72.92%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m37.93%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.53.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28676 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m46.67%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m53.85%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m43.13%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m34.98%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.46.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29716 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m70.77%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m55.80%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m67.70%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m40.86%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.43.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27864 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m44.10%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m55.81%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m37.72%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m36.92%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.41.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29796 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m48.72%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m55.79%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m46.81%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m38.84%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.35.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28708 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_misd_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m74.87%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m52.74%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m67.89%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m39.03%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.34.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26832 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_misd_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m79.49%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m50.32%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m72.53%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m37.07%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.34.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26884 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m71.28%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m55.40%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m63.44%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m41.46%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.33.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27784 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_misd_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m49.23%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m54.17%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m41.97%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m37.33%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.33.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29720 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_misd_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m51.79%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m56.44%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m45.45%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m40.43%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.3.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28656 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m46.15%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m57.78%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m41.01%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m41.04%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.29.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28544 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, juv_other_count = 0, priors_count = (1.0, 5.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m9.74%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m57.89%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m57.89%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\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 and counterfactual cost = 11.0.\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 and counterfactual cost = 11.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m6.58%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m20.59%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m20.59%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\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 and counterfactual cost = 11.0.\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 and counterfactual cost = 11.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.27.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27464 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0, juv_misd_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m46.67%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m56.04%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m37.72%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m39.49%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.26.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28712 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_misd_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m46.15%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m54.44%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m37.33%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m37.82%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.26.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29616 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m80.51%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m49.68%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m75.63%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m37.34%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.26.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26880 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m75.38%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m52.38%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m70.02%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m39.78%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.24.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26700 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0, juv_misd_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m49.23%\u001b[39m covered out of 171\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.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m40.81%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m42.65%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.23.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28644 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0, juv_misd_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m43.59%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m56.47%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m33.66%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m39.66%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.23.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28476 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m71.28%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m55.40%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m64.99%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m42.56%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.23.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27636 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_misd_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m68.72%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m57.46%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m59.19%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m44.44%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.22.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27812 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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 out of 171\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.0.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m83.08%\u001b[39m and counterfactual cost = 1.0.\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 and counterfactual cost = 2.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m25.73%\u001b[39m covered out of 569\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.0.\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.0.\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.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.21.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29884 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, juv_fel_count = 0, juv_other_count = 0, priors_count = (1.0, 5.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m9.23%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m61.11%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m61.11%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\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 and counterfactual cost = 11.0.\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 and counterfactual cost = 11.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m5.61%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m24.14%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m24.14%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\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 and counterfactual cost = 11.0.\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 and counterfactual cost = 11.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.2.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26768 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, priors_count = (1.0, 5.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m31.79%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m74.19%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m82.26%\u001b[39m and counterfactual cost = 1.0.\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.55%\u001b[39m and counterfactual cost = 2.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m24.37%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m55.56%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m68.25%\u001b[39m and counterfactual cost = 1.0.\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[32m85.71%\u001b[39m and counterfactual cost = 2.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.16.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29740 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, priors_count = (1.0, 5.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m13.33%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m42.31%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m42.31%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m96.15%\u001b[39m and counterfactual cost = 10.0.\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[32m96.15%\u001b[39m and counterfactual cost = 11.0.\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 and counterfactual cost = 11.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m9.67%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m14.00%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m14.00%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m86.00%\u001b[39m and counterfactual cost = 10.0.\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[32m88.00%\u001b[39m and counterfactual cost = 11.0.\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 and counterfactual cost = 11.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.14.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25372 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m47.69%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m55.91%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m40.23%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m41.35%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.13.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27704 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 10-25, juv_misd_count = 0, juv_other_count = 0, priors_count = (1.0, 5.0], sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m8.21%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m50.00%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\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 and counterfactual cost = 11.0.\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 and counterfactual cost = 11.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m4.45%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mpriors_count = (-0.1, 1.0]\u001b[39m\u001b[0m with effectiveness \u001b[32m13.04%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = 25 - 45\u001b[39m\u001b[0m with effectiveness \u001b[32m13.04%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m100.00%\u001b[39m and counterfactual cost = 10.0.\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 and counterfactual cost = 11.0.\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 and counterfactual cost = 11.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.11.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24636 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mc_charge_degree = F, juv_fel_count = 0, juv_other_count = 0, sex = Male\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m68.21%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m57.89%\u001b[39m and counterfactual cost = 1.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m59.96%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mc_charge_degree = M\u001b[39m\u001b[0m with effectiveness \u001b[32m46.13%\u001b[39m and counterfactual cost = 1.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.1.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27060 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "If \u001b[1mage_cat = 25 - 45, juv_fel_count = 0, juv_misd_count = 0, juv_other_count = 0\u001b[0m:\n",
      "\tProtected Subgroup '\u001b[1mCaucasian\u001b[0m', \u001b[34m45.13%\u001b[39m covered out of 171\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m57.95%\u001b[39m and counterfactual cost = 10.0.\n",
      "\tProtected Subgroup '\u001b[1mAfrican-American\u001b[0m', \u001b[34m36.17%\u001b[39m covered out of 569\n",
      "\t\tMake \u001b[1m\u001b[31mage_cat = Greater than 45\u001b[39m\u001b[0m with effectiveness \u001b[32m43.32%\u001b[39m and counterfactual cost = 10.0.\n",
      "\t\u001b[35m Unfairness based on the Fair Effectiveness-Cost Trade-Off = 1.1.\u001b[39m\n",
      "\t\u001b[36mCumulative effectiveness plot for the above recourses:\u001b[39m\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 27800 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "affected_pop_sizes = {sg: ((X_test[\"race\"] == sg) & (preds_Xtest == 0)).sum() for sg in X_test[\"race\"].unique()}\n",
    "\n",
    "top_rules,unfairness = facts.select_rules_subset_KStest(\n",
    "    rules_with_cumulative,\n",
    "    affected_pop_sizes,\n",
    "    top_count=50\n",
    ")\n",
    "\n",
    "print_recourse_report_KStest_cumulative(\n",
    "    top_rules,\n",
    "    population_sizes=pop_sizes,\n",
    "    unfairness = unfairness,\n",
    "    show_then_costs=True,\n",
    "    show_cumulative_plots=True\n",
    ")"
   ]
  }
 ],
 "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.8.2"
  },
  "vscode": {
   "interpreter": {
    "hash": "362842c44ed7d38e9c92d488ead4445e1c745f35479a5810177dacafb6456c39"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
