From 5d63a33338c81d2b639e497a7d3f95180c33e367 Mon Sep 17 00:00:00 2001 From: chuningli Date: Wed, 5 Jun 2019 11:01:46 -0400 Subject: updated notebook --- .../metrics_plot/src/constants.py | 6 +- .../src/metrics_distance_with_selector.ipynb | 370 ++++++++++++++++++--- 2 files changed, 324 insertions(+), 52 deletions(-) diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/constants.py b/Metrics/Metrics-Calculation/metrics_plot/src/constants.py index 58ca7549..803bae2e 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/src/constants.py +++ b/Metrics/Metrics-Calculation/metrics_plot/src/constants.py @@ -18,8 +18,8 @@ METAMODEL = 'Meta Mode' STATE_ID = 'State Id' -HUMAN_OUT_D_REP = '../statistics/humanOutput\R_20158_run_1.csv' +HUMAN_OUT_D_REP = '../statistics/humanOutput/R_20158_run_1.csv' -HUMAN_MPC_REP = '../statistics/humanOutput\R_2015246_run_1.csv' +HUMAN_MPC_REP = '../statistics/humanOutput/R_2015246_run_1.csv' -HUMAN_NA_REP = '../statistics/humanOutput\R_2016176_run_1.csv' +HUMAN_NA_REP = '../statistics/humanOutput/R_2016176_run_1.csv' diff --git a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb b/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb index e5868da0..8c57a327 100644 --- a/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb +++ b/Metrics/Metrics-Calculation/metrics_plot/src/metrics_distance_with_selector.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -48,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -139,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -149,7 +149,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -184,7 +184,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -200,7 +200,9 @@ "# Read generated models\n", "viatra_no_con_stats = readStats('../statistics/viatra_nocon_output/', 5000)\n", "viatra_con_stats = readStats('../statistics/viatra_con_output/',5000)\n", - "random_stats = readStats('../statistics/random_output/',5000)" + "random_stats = readStats('../statistics/random_output/',5000)\n", + "real_random_stats = readStats('../statistics/real_random_output/', 10000)\n", + "viatra_500_stats = readStats('../statistics/viatra500nodes/', 10000)" ] }, { @@ -212,18 +214,20 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "viatra_no_con_dic = calDistanceDic(viatra_no_con_stats, human_rep)\n", "viatra_con_dic = calDistanceDic(viatra_con_stats, human_rep)\n", - "random_dic = calDistanceDic(random_stats, human_rep)" + "random_dic = calDistanceDic(random_stats, human_rep)\n", + "real_random_dic = calDistanceDic(real_random_stats, human_rep)\n", + "viatra_500_dic = calDistanceDic(viatra_500_stats, human_rep)" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -249,13 +253,13 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1bdc31418d894783b36cc79c60251f00", + "model_id": "cba63d8050a043018a16db6f1a0440f9", "version_major": 2, "version_minor": 0 }, @@ -272,7 +276,7 @@ "" ] }, - "execution_count": 12, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -285,18 +289,18 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "78565a0ec3d740908fcea753387cfc3e", + "model_id": "3c07dab0b6fd4c45b0168d206e99e4ea", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra_noc…" + "interactive(children=(SelectMultiple(description='Trajectory:', index=(11,), options={'../statistics/viatra_no…" ] }, "metadata": {}, @@ -308,7 +312,7 @@ "" ] }, - "execution_count": 13, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -321,18 +325,18 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "4392eb19fe1844c4affeb62f9ba9163b", + "model_id": "f3bb86160c964b5383bda7cdee81a1b7", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra_noc…" + "interactive(children=(SelectMultiple(description='Trajectory:', index=(11,), options={'../statistics/viatra_no…" ] }, "metadata": {}, @@ -344,7 +348,7 @@ "" ] }, - "execution_count": 14, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -357,18 +361,44 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 35, + "metadata": {}, + "outputs": [], + "source": [ + "filenames = reader.readmultiplefiles('../statistics/viatra_con_output/trajectories/', 15, False)\n", + "trajectories = {}\n", + "for name in filenames:\n", + " trajectories[name] = reader.readTrajectory(name)\n", + "\n", + "w = widgets.SelectMultiple(\n", + " options = trajectories,\n", + " value = [trajectories[filenames[0]]],\n", + " description='Trajectory:',\n", + " disabled=False,\n", + ")\n", + "\n", + "#generate random color for each line\n", + "colors = []\n", + "\n", + "for i in range(0, len(trajectories)):\n", + " color = \"#%06x\" % random.randint(0, 0xFFFFFF)\n", + " colors.append(color)" + ] + }, + { + "cell_type": "code", + "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c667f0f9dcd5494f81d95c64ad900612", + "model_id": "ec10c88d57f14461b160572e0a3f4e0d", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "interactive(children=(Dropdown(description='lines', options=([],), value=[]), Output()), _dom_classes=('widget…" + "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra_con…" ] }, "metadata": {}, @@ -380,7 +410,7 @@ "" ] }, - "execution_count": 15, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -388,23 +418,23 @@ "source": [ "def plot_out_degree(lines):\n", " plot(viatra_con_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree')\n", - "interact(plot_out_degree, lines=[[]])" + "interact(plot_out_degree, lines=w)" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "991d8d2bfc644c82a9b079615900dc4d", + "model_id": "bde0cb7466f64699be0159a8404eb821", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "interactive(children=(Dropdown(description='lines', options=([],), value=[]), Output()), _dom_classes=('widget…" + "interactive(children=(SelectMultiple(description='Trajectory:', index=(3,), options={'../statistics/viatra_con…" ] }, "metadata": {}, @@ -416,7 +446,7 @@ "" ] }, - "execution_count": 16, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -424,23 +454,23 @@ "source": [ "def plot_na(lines):\n", " plot(viatra_con_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity')\n", - "interact(plot_na, lines=[[]])" + "interact(plot_na, lines=w)" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "be65f39c2fae4c84a1d6908f3b70a86e", + "model_id": "9fda08a154104d80aca9d6eef3404bf1", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "interactive(children=(Dropdown(description='lines', options=([],), value=[]), Output()), _dom_classes=('widget…" + "interactive(children=(SelectMultiple(description='Trajectory:', index=(3,), options={'../statistics/viatra_con…" ] }, "metadata": {}, @@ -452,7 +482,7 @@ "" ] }, - "execution_count": 17, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -460,18 +490,18 @@ "source": [ "def plot_mpc(lines):\n", " plot(viatra_con_dic, lines, 0, lambda a: a.mpc_distance, colors, 'MPC')\n", - "interact(plot_mpc, lines=[[]])" + "interact(plot_mpc, lines=w)" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1de0db5b5c8d46de958f6b43144dac54", + "model_id": "5f4859e7657a4080b8ee0db66ad70b04", "version_major": 2, "version_minor": 0 }, @@ -488,7 +518,7 @@ "" ] }, - "execution_count": 18, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -501,13 +531,121 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "fd6387994c764904b20975a54b47bf3a", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='lines', options=([],), value=[]), Output()), _dom_classes=('widget…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_out_degree(lines):\n", + " plot(random_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity')\n", + "interact(plot_out_degree, lines=[[]])" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "27e3897451694ffb8af3dd32bc0ece70", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='lines', options=([],), value=[]), Output()), _dom_classes=('widget…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_out_degree(lines):\n", + " plot(random_dic, lines, 0, lambda a: a.mpc_distance, colors, 'MPC')\n", + "interact(plot_out_degree, lines=[[]])" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "f4d0964368254b599c7cb8d6b6f9a0f4", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='lines', options=([],), value=[]), Output()), _dom_classes=('widget…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_out_degree(lines):\n", + " plot(real_random_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree')\n", + "interact(plot_out_degree, lines=[[]])" + ] + }, + { + "cell_type": "code", + "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "6f8fa855125b4beca603abbf801412ac", + "model_id": "eca026dd74a945bcbebde5cb69cfe0e2", "version_major": 2, "version_minor": 0 }, @@ -524,26 +662,26 @@ "" ] }, - "execution_count": 20, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def plot_out_degree(lines):\n", - " plot(random_dic, lines, 0, lambda a: a.na_distance, colors, 'out degree')\n", + " plot(real_random_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity')\n", "interact(plot_out_degree, lines=[[]])" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "b4ed2adb29004908a3799bc91bf0662b", + "model_id": "eff1d3cd5d1a4a85b56024362890759c", "version_major": 2, "version_minor": 0 }, @@ -560,17 +698,151 @@ "" ] }, - "execution_count": 23, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def plot_out_degree(lines):\n", - " plot(random_dic, lines, 0, lambda a: a.mpc_distance, colors, 'out degree')\n", + " plot(real_random_dic, lines, 0, lambda a: a.mpc_distance, colors, 'MPC')\n", "interact(plot_out_degree, lines=[[]])" ] }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "filenames = reader.readmultiplefiles('../statistics/viatra500nodes/trajectories/', 15, False)\n", + "trajectories = {}\n", + "for name in filenames:\n", + " trajectories[name] = reader.readTrajectory(name)\n", + "\n", + "w = widgets.SelectMultiple(\n", + " options = trajectories,\n", + " value = [trajectories[filenames[0]]],\n", + " description='Trajectory:',\n", + " disabled=False,\n", + ")\n", + "\n", + "#generate random color for each line\n", + "colors = []\n", + "\n", + "for i in range(0, len(trajectories)):\n", + " color = \"#%06x\" % random.randint(0, 0xFFFFFF)\n", + " colors.append(color)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "e281415e80684a85ba24ab8cb48ea3fe", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra500n…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_out_degree(lines):\n", + " plot(viatra_500_dic, lines, 0, lambda a: a.na_distance, colors, 'node activity')\n", + "interact(plot_out_degree, lines=w)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d678fee844e84e2785d50945288f833d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra500n…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_out_degree(lines):\n", + " plot(viatra_500_dic, lines, 0, lambda a: a.out_d_distance, colors, 'out degree')\n", + "interact(plot_out_degree, lines=w)" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "55ca7c3f89224cce8d3a87cf23b20f92", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(SelectMultiple(description='Trajectory:', index=(0,), options={'../statistics/viatra500n…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def plot_out_degree(lines):\n", + " plot(viatra_500_dic, lines, 0, lambda a: a.mpc_distance, colors, 'mpc')\n", + "interact(plot_out_degree, lines=w)" + ] + }, { "cell_type": "code", "execution_count": null, -- cgit v1.2.3-54-g00ecf