Files
Aconity_ML_Expt1/expt1_analysis.ipynb
2023-08-03 21:33:03 +01:00

134 lines
2.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Data handling imports\n",
"import numpy as np\n",
"import pickle\n",
"import random\n",
"from tqdm.auto import tqdm\n",
"import optuna"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"storage_name = \"mysql+pymysql://root:Ch31121992@192.168.1.10:3306/optuna_db\"\n",
"study_name = \"Experiment 1\"\n",
"study = optuna.load_study(\n",
" study_name=study_name,\n",
" storage=storage_name,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df = study.trials_dataframe()\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.dropna(inplace=True)\n",
"df.sort_values(by=\"value\", inplace=True)\n",
"df.drop(df[\"value\"].idxmax(), inplace=True)\n",
"df.drop(df[\"value\"].idxmax(), inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"pd.options.plotting.backend = \"plotly\"\n",
"params = list(df.keys()[5:-1])\n",
"for p in params:\n",
" df.plot(x=p, y=\"value\", kind=\"scatter\", title=p)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"params = list(df.keys()[5:-1])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!poetry add tabulate\n",
"from tabulate import tabulate\n",
"print(\n",
" tabulate(\n",
" (x[0] for x in sorted(list(df.groupby(params)), key=lambda x: x[1][\"value\"].mean())),\n",
" headers = params,\n",
" tablefmt = \"grid\",\n",
" )\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for p in params:\n",
" df.plot(x=p, y=\"value\", kind=\"scatter\", title=p).show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.11.3"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}