{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 106560 characters]",
      "text/plain": [
       "<Figure size 1200x700 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.patches as mpatches\n",
    "\n",
    "folds = ['Fold 1', 'Fold 2', 'Fold 3', 'Fold 4', 'Fold 5']\n",
    "TinyBert = [91.29, 88.32, 93.57, 94.24, 91.71]\n",
    "Albert = [86.46, 88.5, 94.33, 94.53, 86.49]\n",
    "DistilBert = [92.19, 90.19, 95.28, 95.67, 91.98]\n",
    "Bert = [92.19, 89.95, 95.13, 95.1, 91.66]\n",
    "\n",
    "data = np.array([TinyBert, Albert, DistilBert, Bert])\n",
    "max_indices = np.argmax(data, axis=0)\n",
    "\n",
    "x = np.arange(len(folds))\n",
    "width = 0.2\n",
    "colors = plt.cm.Spectral(np.linspace(0, 1, 4))\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(12,7))\n",
    "\n",
    "labels = ['TinyBert', 'Albert', 'DistilBert', 'Bert']\n",
    "rects = []\n",
    "for i in range(4):\n",
    "    rect = ax.bar(x + (i - 1.5)*width, data[i], width, label=labels[i], color=colors[i], edgecolor='black', linewidth=1.5, zorder=3)\n",
    "    rects.append(rect)\n",
    "\n",
    "for fold in range(len(folds)):\n",
    "    max_idx = max_indices[fold]\n",
    "    rects[max_idx].patches[fold].set_hatch('//')\n",
    "\n",
    "TinyBert_mean = np.mean(TinyBert)\n",
    "Albert_mean = np.mean(Albert)\n",
    "DistilBert_mean = np.mean(DistilBert)\n",
    "Bert_mean = np.mean(Bert)\n",
    "\n",
    "ax.axhline(y=TinyBert_mean, color=colors[0], linestyle='--', label='TinyBert Mean', zorder=2)\n",
    "ax.axhline(y=Albert_mean, color=colors[1], linestyle='--', zorder=2)\n",
    "ax.axhline(y=DistilBert_mean, color=colors[2], linestyle='--', zorder=2)\n",
    "ax.axhline(y=Bert_mean, color=colors[3], linestyle='--', label='Bert Mean', zorder=2)\n",
    "\n",
    "max_mean = max(TinyBert_mean, Albert_mean, DistilBert_mean, Bert_mean)\n",
    "min_mean = min(TinyBert_mean, Albert_mean, DistilBert_mean, Bert_mean)\n",
    "\n",
    "ax.text(x[1], max_mean + 0.5, f'Max: {max_mean:.2f}%', ha='center', fontsize=20, color='black', zorder=3)\n",
    "ax.text(x[1], min_mean + 0.5, f'Min: {min_mean:.2f}%', ha='center', fontsize=20, color='black', zorder=3)\n",
    "\n",
    "ax.set_ylim([85, 100])\n",
    "ax.set_xticks(x)\n",
    "ax.set_xticklabels(folds, fontsize=20)\n",
    "ax.grid(True, which='both', linestyle='--', linewidth=0.7, alpha=0.7, zorder=1)\n",
    "ax.tick_params(axis='both', which='major', labelsize=20)\n",
    "\n",
    "hatch_patch = mpatches.Patch(facecolor='white', edgecolor='black', hatch='//', label='BEST')\n",
    "legend_handles, legend_labels = ax.get_legend_handles_labels()\n",
    "legend = ax.legend(handles=[hatch_patch] + legend_handles, fontsize=20, loc='upper right')\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "torch",
   "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.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
