{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from plot import plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [],
   "source": [
    "# name = 'res'\n",
    "name = 'vgg16'\n",
    "path = 'save_compare_data/'\n",
    "dataset = 'celeba'\n",
    "dataset_used = 'celeba'\n",
    "\n",
    "total_acc = np.load(path + name + '_total_acc.npz')['total_acc']\n",
    "total_balanced_acc = np.load(path + name + '_total_balanced_acc.npz')['total_balanced_acc']\n",
    "total_disimpact = np.load(path + name + '_total_disimpact.npz')['total_disimpact']\n",
    "total_eqopp_diff = np.load(path + name + '_total_eqopp_diff.npz')['total_eqopp_diff']\n",
    "total_aveodds_diff = np.load(path + name + '_total_aveodds_diff.npz')['total_aveodds_diff']\n",
    "total_theil_idx = np.load(path + name + '_total_theil_idx.npz')['total_theil_idx']\n",
    "stat_parity_diff = np.load(path + name + '_stat_parity_diff.npz')['stat_parity_diff']\n",
    "total_tpr = np.load(path + name + '_total_tpr.npz')['total_tpr']\n",
    "total_fpr_diff = np.load(path + name + '_total_fpr_diff.npz')['total_fpr_diff']\n",
    "total_aveodds_diff = 0.5 * (abs(total_fpr_diff) + abs(total_eqopp_diff))\n",
    "name +='_sex'\n",
    "# name = 'res50' + '_sex'\n",
    "\n",
    "laftr_dir= '/home/taeuk/network/git/laftr/experiments/result/{}/'.format(dataset + '_' + name)\n",
    "\n",
    "total_acc[8, :] = np.load(laftr_dir + 'laftr_ACC.npy')[1:4]\n",
    "total_tpr[8, :] = np.load(laftr_dir + 'laftr_A=?_TPR.npy')[1:4]\n",
    "total_eqopp_diff[8, :] = np.load(laftr_dir + 'laftr_Eq_Opp_diff.npy')[1:4]\n",
    "total_aveodds_diff[8, :] = np.load(laftr_dir + 'laftr_Av_abs_odd_diff.npy')[1:4]\n",
    "total_disimpact[8, :] = np.load(laftr_dir + 'laftr_DISP.npy')[1:4]\n",
    "\n",
    "name = name.split('_')[0]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 18744 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 22580 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 22208 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 22976 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 17648 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "setting = 'best/' + dataset + '/' + name\n",
    "dataset_used = 'celeba_'+name\n",
    "plot(total_acc, 0, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n",
    "# plot(total_balanced_acc, 1, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n",
    "plot(np.abs(1-total_disimpact), 2, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n",
    "plot(np.abs(total_eqopp_diff), 3, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n",
    "plot(np.abs(total_aveodds_diff), 4, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n",
    "# plot(np.abs(total_theil_idx), 5, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n",
    "# plot(np.abs(stat_parity_diff), 6, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n",
    "plot(np.abs(total_tpr), 7, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n",
    "# plot(np.abs(total_fpr_diff), 8, dataset_used, setting, method_idx = [10,1,2,3,6,8,9], show = True, save = True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:aif]",
   "language": "python",
   "name": "conda-env-aif-py"
  },
  "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.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
