Skip to content

Commit

Permalink
fixed notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphonsce committed May 9, 2024
1 parent 68d1607 commit b472415
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 3,169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -11,14 +11,15 @@
"\n",
"import seaborn as sns\n",
"import numpy as np\n",
"import os\n",
"\n",
"import matplotlib.pyplot as plt\n",
"sns.set_style(\"white\", {\"grid.color\": \".6\", \"grid.linestyle\": \":\"})"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -48,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -68,7 +69,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -140,41 +141,45 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"for project in detection_projects:\n",
" os.makedirs(\"./detection\", exist_ok=True)\n",
" get_runs_df(project, resolution=True, runtime_limit=4 * 3600).to_csv(f\"./detection/{project}.csv\", index=False, columns=detection_cols)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"for project in fid_projects:\n",
" os.makedirs(\"./fid\", exist_ok=True)\n",
" get_runs_df(project).sort_values(by=\"name\", ascending=False).to_csv(f\"./fid/{project}.csv\", index=False, columns=fid_cols)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"for project in stable_signature_detection_projects:\n",
" os.makedirs(\"./detection\", exist_ok=True)\n",
" get_runs_df_stable_sig(project, runtime_limit=0).to_csv(f\"./detection/{project}.csv\", index=False, columns=stable_signature_detection_cols)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"clip_different_message = \"clip_different_msg\"\n",
"os.makedirs(\"./detection\", exist_ok=True)\n",
"get_runs_df(clip_different_message, runtime_limit=0, resolution=True).sort_values(by=\"name\", ascending=False).to_csv(f\"./detection/{clip_different_message}.csv\", index=False, columns=detection_cols)"
]
}
Expand Down
337 changes: 0 additions & 337 deletions plots/diff_attacks/plotting.ipynb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 166,
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 167,
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -49,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": 168,
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -61,7 +61,7 @@
},
{
"cell_type": "code",
"execution_count": 169,
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -72,7 +72,7 @@
},
{
"cell_type": "code",
"execution_count": 170,
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -81,15 +81,12 @@
"acc = df_msg[\"acc\"]\n",
"auc = df_msg[\"auc\"]\n",
"\n",
"detect_metrics = ['''TPR@1%FPR''', \"acc\", \"auc\"]\n",
"positions = [\n",
" [0, 1], [2, 0], [2, 2]\n",
"]"
"detect_metrics = ['''TPR@1%FPR''', \"acc\", \"auc\"]"
]
},
{
"cell_type": "code",
"execution_count": 171,
"execution_count": 30,
"metadata": {},
"outputs": [
{
Expand All @@ -107,7 +104,7 @@
"fig, ax = plt.subplots(figsize=(8, 6))\n",
"\n",
"\n",
"for metric, pos in zip(detect_metrics, positions):\n",
"for metric in detect_metrics:\n",
" # plt.subplot2grid((4, 4), pos, rowspan=2, colspan=2)\n",
"\n",
" ax.plot(\n",
Expand Down Expand Up @@ -146,68 +143,16 @@
},
{
"cell_type": "code",
"execution_count": 172,
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>TPR@1%FPR</th>\n",
" <th>acc</th>\n",
" <th>auc</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>490</td>\n",
" <td>0.099448</td>\n",
" <td>0.685083</td>\n",
" <td>0.690867</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name TPR@1%FPR acc auc\n",
"1 490 0.099448 0.685083 0.690867"
]
},
"execution_count": 172,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"df_detect = pd.read_csv(\"long_diff.csv\")[[\"Name\", '''TPR@1%FPR''', \"acc\", \"auc\"]].iloc[1::2, :]\n",
"\n",
"df_detect[\"Name\"] = df_detect[\"Name\"].map(lambda x: int(x.replace(\"s_\", \"\")))\n",
"df_detect.head(1)"
"df_detect = get_runs_df(\"new_big_diff_attacks\")[['''TPR@1%FPR''', \"acc\", \"auc\"]].iloc[1::2, :]"
]
},
{
"cell_type": "code",
"execution_count": 173,
"execution_count": 32,
"metadata": {},
"outputs": [
{
Expand All @@ -227,8 +172,7 @@
"fig, ax = plt.subplots(figsize=(8, 6))\n",
"\n",
"\n",
"for metric, pos in zip(detect_metrics, positions):\n",
" # plt.subplot2grid((4, 4), pos, rowspan=2, colspan=2)\n",
"for metric in detect_metrics:\n",
"\n",
" ax.plot(\n",
" steps, df_detect[metric], '--o', label=metric, markersize=markersize\n",
Expand Down Expand Up @@ -275,7 +219,7 @@
},
{
"cell_type": "code",
"execution_count": 174,
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -286,7 +230,7 @@
},
{
"cell_type": "code",
"execution_count": 175,
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -295,15 +239,12 @@
"acc = df_msg[\"acc\"]\n",
"auc = df_msg[\"auc\"]\n",
"\n",
"detect_metrics = ['''TPR@1%FPR''', \"acc\", \"auc\"]\n",
"positions = [\n",
" [0, 1], [2, 0], [2, 2]\n",
"]"
"detect_metrics = ['''TPR@1%FPR''', \"acc\", \"auc\"]"
]
},
{
"cell_type": "code",
"execution_count": 176,
"execution_count": 35,
"metadata": {},
"outputs": [
{
Expand All @@ -320,8 +261,7 @@
"source": [
"fig, ax = plt.subplots(figsize=(8, 6))\n",
"\n",
"for metric, pos in zip(detect_metrics, positions):\n",
" # plt.subplot2grid((4, 4), pos, rowspan=2, colspan=2)\n",
"for metric in detect_metrics:\n",
"\n",
" ax.plot(\n",
" quality, df_msg[metric], '--o', label=metric, markersize=markersize\n",
Expand Down Expand Up @@ -355,80 +295,25 @@
},
{
"cell_type": "code",
"execution_count": 177,
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>TPR@1%FPR</th>\n",
" <th>acc</th>\n",
" <th>auc</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>8</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name TPR@1%FPR acc auc\n",
"0 8 1.0 1.0 1.0"
]
},
"execution_count": 177,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"df_detect = pd.read_csv(\"2018_detect.csv\")[[\"Name\", '''TPR@1%FPR''', \"acc\", \"auc\"]]\n",
"\n",
"df_detect[\"Name\"] = df_detect[\"Name\"].map(lambda x: int(x.replace(\"vae_2018_\", \"\")))\n",
"df_detect.head(1)"
"df_detect = get_runs_df(\"vae_2018_attacks\")[['''TPR@1%FPR''', \"acc\", \"auc\"]]"
]
},
{
"cell_type": "code",
"execution_count": 178,
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"detect_metrics = ['''TPR@1%FPR''', \"acc\", \"auc\"]\n",
"positions = [\n",
" [0, 1], [2, 0], [2, 2]\n",
"]"
"detect_metrics = ['''TPR@1%FPR''', \"acc\", \"auc\"]"
]
},
{
"cell_type": "code",
"execution_count": 179,
"execution_count": 38,
"metadata": {},
"outputs": [
{
Expand All @@ -445,8 +330,7 @@
"source": [
"fig, ax = plt.subplots(figsize=(8, 6))\n",
"\n",
"for metric, pos in zip(detect_metrics, positions):\n",
" # plt.subplot2grid((4, 4), pos, rowspan=2, colspan=2)\n",
"for metric in detect_metrics:\n",
"\n",
" ax.plot(\n",
" quality, df_detect[metric], '--o', label=metric, markersize=markersize\n",
Expand Down
Loading

0 comments on commit b472415

Please sign in to comment.