nlql / playground_check_eval.ipynb
playground_check_eval.ipynb
Raw
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path\n",
    "import json\n",
    "import pandas as pd\n",
    "\n",
    "eval_path = Path.cwd() / 'eval'\n",
    "dfs = []\n",
    "for i in range(1,4):\n",
    "    file_path = eval_path / f'predictions_eval_v{i}_T5_large.json'\n",
    "    with open(file_path, 'r') as f_in:\n",
    "        data = json.load(f_in)\n",
    "        df = pd.DataFrame.from_records(data, columns=['db_id','question', 'query', 'prediction'])\n",
    "        df['prediction'] = df.apply(lambda x: x['prediction'].split('|')[-1].strip(), axis=1)\n",
    "        dfs.append(df)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_341950/2288969719.py:5: FutureWarning: save is not part of the public API, usage can give unexpected results and will be removed in a future version\n",
      "  writer.save()\n"
     ]
    }
   ],
   "source": [
    "xlsx_path = eval_path / 't5_large_zero_shot_eval.xlsx'\n",
    "with pd.ExcelWriter(xlsx_path, engine='openpyxl') as writer:\n",
    "    for df in dfs:\n",
    "        df.to_excel(writer, sheet_name=df['db_id'][0])\n",
    "    writer.save()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "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.16"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}