Skip to content

Commit

Permalink
Fix visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-perseus committed Dec 2, 2023
1 parent 010f427 commit a046777
Showing 1 changed file with 27 additions and 178 deletions.
205 changes: 27 additions & 178 deletions model/W&B_PPSG_LSTM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,24 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"outputs": [],
"source": [
"import wandb"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-12-02T09:21:03.013163Z",
"start_time": "2023-12-02T09:21:01.337582Z"
}
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 3,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001B[34m\u001B[1mwandb\u001B[0m: Currently logged in as: \u001B[33mmr-perseus\u001B[0m (\u001B[33mparcaster\u001B[0m). Use \u001B[1m`wandb login --relogin`\u001B[0m to force relogin\n"
]
},
{
"data": {
"text/plain": "True"
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": null,
"outputs": [],
"source": [
"wandb.login()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-12-02T09:21:15.255870Z",
"start_time": "2023-12-02T09:21:11.602511Z"
}
"collapsed": false
}
},
{
Expand All @@ -105,13 +81,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"id": "ilZtMXIA5qMC",
"ExecuteTime": {
"end_time": "2023-12-02T09:21:18.284559Z",
"start_time": "2023-12-02T09:21:18.247259Z"
}
"id": "ilZtMXIA5qMC"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -171,24 +143,11 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"id": "1PbIZ_xm5qMG",
"ExecuteTime": {
"end_time": "2023-12-02T09:21:20.000574Z",
"start_time": "2023-12-02T09:21:19.363937Z"
}
"id": "1PbIZ_xm5qMG"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Create sweep with ID: 77qlzfw6\n",
"Sweep URL: https://wandb.ai/parcaster/pp-sg-lstm/sweeps/77qlzfw6\n"
]
}
],
"outputs": [],
"source": [
"sweep_id = wandb.sweep(sweep_config, project=\"pp-sg-lstm\")"
]
Expand Down Expand Up @@ -222,23 +181,11 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {
"id": "UMlizVTr5qMG",
"ExecuteTime": {
"end_time": "2023-12-02T09:23:59.537228Z",
"start_time": "2023-12-02T09:23:59.485763Z"
}
"id": "UMlizVTr5qMG"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training on cpu\n"
]
}
],
"outputs": [],
"source": [
"import os\n",
"import torch\n",
Expand Down Expand Up @@ -295,7 +242,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"outputs": [],
"source": [
"def load_features_labels(csv_path):\n",
Expand All @@ -319,11 +266,7 @@
" return X_train, X_val, y_train, y_val"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-12-02T09:26:02.009390Z",
"start_time": "2023-12-02T09:26:01.971428Z"
}
"collapsed": false
}
},
{
Expand All @@ -342,13 +285,9 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {
"id": "PMNNnYkr5qMG",
"ExecuteTime": {
"end_time": "2023-12-02T09:26:03.045538Z",
"start_time": "2023-12-02T09:26:02.997434Z"
}
"id": "PMNNnYkr5qMG"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -445,13 +384,13 @@
"execution_count": null,
"outputs": [],
"source": [
"def plot_test_prediction(output, target):\n",
" df_output = pd.DataFrame(output, columns=parking_data_labels)\n",
" df_target = pd.DataFrame(target, columns=parking_data_labels)\n",
"def plot_test_prediction(outputs, targets):\n",
" for i, (output, target) in enumerate(zip(outputs, targets)):\n",
" df_output = pd.DataFrame(output, columns=parking_data_labels)\n",
" df_target = pd.DataFrame(target, columns=parking_data_labels)\n",
"\n",
" n_features = len(df_output.columns)\n",
" n_features = len(df_output.columns)\n",
"\n",
" for i in range(len(df_target)):\n",
" # Plotting\n",
" fig, ax = plt.subplots(figsize=(10, 6))\n",
"\n",
Expand All @@ -460,8 +399,8 @@
" width = 0.35 # the width of the bars\n",
"\n",
" # Plotting bars for each row\n",
" bars1 = ax.bar(ind - width / 2, df_output.iloc[i], width, label='Prediction (from model)')\n",
" bars2 = ax.bar(ind + width / 2, df_target.iloc[i], width, label='Target (form dataset)')\n",
" bars1 = ax.bar(ind - width / 2, df_output.iloc[0], width, label='Prediction (from model)')\n",
" bars2 = ax.bar(ind + width / 2, df_target.iloc[0], width, label='Target (form dataset)')\n",
"\n",
" # Adding some text for labels, title, and custom x-axis tick labels\n",
" ax.set_xlabel('Parking garages')\n",
Expand Down Expand Up @@ -506,101 +445,11 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {
"id": "KjgClaFq5qMH",
"ExecuteTime": {
"end_time": "2023-12-02T09:29:12.923109Z",
"start_time": "2023-12-02T09:26:04.744307Z"
}
"id": "KjgClaFq5qMH"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001B[34m\u001B[1mwandb\u001B[0m: Agent Starting Run: 0ip9dcnd with config:\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \tbatch_size: 40\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \tdropout: 0.1\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \tepochs: 5\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \tfc_layer_size: 200\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \tlearning_rate: 0.07169443531449272\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \tmodel: lstm\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \tnum_layers: 4\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \toptimizer: adam\n",
"\u001B[34m\u001B[1mwandb\u001B[0m: \ttrain_val_ratio: 0.8\n"
]
},
{
"data": {
"text/plain": "<IPython.core.display.HTML object>",
"text/html": "Tracking run with wandb version 0.16.0"
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": "<IPython.core.display.HTML object>",
"text/html": "Run data is saved locally in <code>/Users/jan/Projects/parcaster/model/wandb/run-20231202_102609-0ip9dcnd</code>"
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": "<IPython.core.display.HTML object>",
"text/html": "Syncing run <strong><a href='https://wandb.ai/parcaster/pp-sg-lstm/runs/0ip9dcnd' target=\"_blank\">dashing-sweep-4</a></strong> to <a href='https://wandb.ai/parcaster/pp-sg-lstm' target=\"_blank\">Weights & Biases</a> (<a href='https://wandb.me/run' target=\"_blank\">docs</a>)<br/>Sweep page: <a href='https://wandb.ai/parcaster/pp-sg-lstm/sweeps/77qlzfw6' target=\"_blank\">https://wandb.ai/parcaster/pp-sg-lstm/sweeps/77qlzfw6</a>"
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": "<IPython.core.display.HTML object>",
"text/html": " View project at <a href='https://wandb.ai/parcaster/pp-sg-lstm' target=\"_blank\">https://wandb.ai/parcaster/pp-sg-lstm</a>"
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": "<IPython.core.display.HTML object>",
"text/html": " View sweep at <a href='https://wandb.ai/parcaster/pp-sg-lstm/sweeps/77qlzfw6' target=\"_blank\">https://wandb.ai/parcaster/pp-sg-lstm/sweeps/77qlzfw6</a>"
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": "<IPython.core.display.HTML object>",
"text/html": " View run at <a href='https://wandb.ai/parcaster/pp-sg-lstm/runs/0ip9dcnd' target=\"_blank\">https://wandb.ai/parcaster/pp-sg-lstm/runs/0ip9dcnd</a>"
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Input dimension: 18, columns: Index(['ferien', 'feiertag', 'covid_19', 'olma_offa', 'temperature_2m_max',\n",
" 'temperature_2m_min', 'rain_sum', 'snowfall_sum', 'sin_minute',\n",
" 'cos_minute', 'sin_hour', 'cos_hour', 'sin_weekday', 'cos_weekday',\n",
" 'sin_day', 'cos_day', 'sin_month', 'cos_month'],\n",
" dtype='object')\n",
"Output dimension: 14, columns: Index(['P24', 'P44', 'P42', 'P33', 'P23', 'P25', 'P21', 'P31', 'P53', 'P32',\n",
" 'P22', 'P52', 'P51', 'P43'],\n",
" dtype='object')\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001B[34m\u001B[1mwandb\u001B[0m: Ctrl + C detected. Stopping sweep.\n"
]
}
],
"outputs": [],
"source": [
"wandb.agent(sweep_id, train, count=1)"
]
Expand Down

0 comments on commit a046777

Please sign in to comment.