{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bd57234d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8f20cfe9",
   "metadata": {},
   "outputs": [],
   "source": [
    "info = pd.read_csv(\"/home/tabsemi_v2/results/benchmark_stats.csv\", index_col=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3e721ae5",
   "metadata": {},
   "outputs": [],
   "source": [
    "datalist = [\n",
    "    22, 54, 1063, 1067, 12, 18, 23, 59, 188, 307, 1043, 1459, 1475, 1489, 1492, 1497, 1503, 4153, 40499, 44125,\n",
    "    44131, 45062, 44157, 1462, 44160, 29, 37, 53, 49, 1504, 1494, 41143, 44126, 40981, 41168, 44091, 44158, 44123, 44090,\n",
    "    40922, 44161, 45714]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b5d264bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "info = info.loc[info[\"data_id\"].isin(datalist)][[\"data_id\", \"tasktype\", \"num_prep_data\", \"num_prep_features\", \"num_classes\"]]\n",
    "info[\"num_classes\"] = info[\"num_classes\"].fillna(2)\n",
    "info = info.sort_values(\"num_classes\").reset_index(drop=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "34468eb6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  2.,   3.,   4.,   5.,   6.,  10.,  11., 100.])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info[\"num_classes\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "6d23874c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 22328 characters]\n",
      "text/plain": [
       "<Figure size 288x216 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "p1 = info[info[\"num_classes\"] == 2]\n",
    "p2 = info[(info[\"num_classes\"] > 2) & (info[\"num_classes\"] < 10)]\n",
    "p3 = info[(info[\"num_classes\"] > 9)]\n",
    "\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.gca().set_axisbelow(True)\n",
    "plt.grid()\n",
    "plt.scatter(p1[\"num_prep_data\"], p1[\"num_prep_features\"], label=\"Binary\")\n",
    "plt.scatter(p2[\"num_prep_data\"], p2[\"num_prep_features\"], label=\"Multiclass\\n(Less than\\n10 classes)\")\n",
    "plt.scatter(p3[\"num_prep_data\"], p3[\"num_prep_features\"], label=\"Multiclass\\n(More than\\n10 classes)\")\n",
    "# plt.colorbar()\n",
    "plt.legend(loc=(1.02, 0.12), labelspacing=1)\n",
    "plt.xscale('log')\n",
    "plt.yscale('log')\n",
    "plt.xlabel(\"Data size (log scale)\", fontsize=12)\n",
    "plt.ylabel(\"Feature dimension\\n(log scale)\", fontsize=12)\n",
    "plt.savefig(\"figs/benchmark_overview.png\", dpi=300, bbox_inches=\"tight\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "e1431765",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info[\"num_prep_features\"].min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7b2173e3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
