Skip to content

Commit b68de44

Browse files
committed
Updated eval script for monkey comparison with c model
1 parent 33376b2 commit b68de44

File tree

1 file changed

+39
-36
lines changed

1 file changed

+39
-36
lines changed

evaluation/plot_monkey_tester_c_model.ipynb

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
"outputs": [],
99
"source": [
1010
"import numpy as np\n",
11-
"from matplotlib import pyplot as plt"
11+
"from matplotlib import pyplot as plt\n",
12+
"import os\n",
13+
"\n",
14+
"os.chdir(\"../\")"
1215
]
1316
},
1417
{
1518
"cell_type": "markdown",
1619
"id": "a373b877-d487-4ccf-afd8-cefa968d8a0f",
17-
"metadata": {},
20+
"metadata": {
21+
"tags": []
22+
},
1823
"source": [
1924
"# Plot of three monkey testers compared with the Approach\n",
2025
"\n",
@@ -33,12 +38,12 @@
3338
"metadata": {},
3439
"outputs": [],
3540
"source": [
36-
"random_monkey_dir = \"\"\n",
37-
"random_widget_monkey_dir = \"\"\n",
38-
"random_widget_monkey_zero_random_click_prob_dir = \"\"\n",
41+
"random_monkey_dir = \"datasets/gui_env/random-clicks/2022-04-20_14-02-28\"\n",
42+
"random_widget_monkey_dir = \"datasets/gui_env/random-widgets/2022-04-20_14-03-07\"\n",
43+
"random_widget_monkey_zero_random_click_prob_dir = \"datasets/gui_env/random-widgets/2022-04-20_14-04-12\"\n",
3944
"\n",
40-
"first_controller_model_file = \"\"\n",
41-
"second_controller_model_file = \"\""
45+
"first_controller_model_file = \"controller_v_103_eval.npz\"\n",
46+
"second_controller_model_file = \"controller_v_76_eval.npz\""
4247
]
4348
},
4449
{
@@ -52,7 +57,7 @@
5257
"random_widget_monkey_rewards = []\n",
5358
"random_widget_monkey_zero_random_click_prob_rewards = []\n",
5459
"\n",
55-
"for monkey_dir in monkey_tester_dirs:\n",
60+
"for i in range(3):\n",
5661
" \n",
5762
" if i == 0:\n",
5863
" monkey_dir = random_monkey_dir\n",
@@ -72,13 +77,13 @@
7277
" sequence_data = np.load(os.path.join(monkey_dir, seq_dir, \"data.npz\"))\n",
7378
" reward_list.append(sequence_data[\"rewards\"])\n",
7479
" \n",
75-
"random_monkey_mean = np.mean(random_monkey_rewards, axis=0)\n",
80+
"random_monkey_mean = np.mean(random_monkey_rewards, axis=0).cumsum()\n",
7681
"random_monkey_std = np.std(random_monkey_rewards, axis=0)\n",
7782
"\n",
78-
"random_widget_monkey_mean = np.mean(random_widget_monkey_rewards, axis=0)\n",
83+
"random_widget_monkey_mean = np.mean(random_widget_monkey_rewards, axis=0).cumsum()\n",
7984
"random_widget_monkey_std = np.std(random_widget_monkey_rewards, axis=0)\n",
8085
"\n",
81-
"random_widget_monkey_zero_random_click_prob_mean = np.mean(random_widget_monkey_zero_random_click_prob_rewards, axis=0)\n",
86+
"random_widget_monkey_zero_random_click_prob_mean = np.mean(random_widget_monkey_zero_random_click_prob_rewards, axis=0).cumsum()\n",
8287
"random_widget_monkey_zero_random_click_prob_std = np.std(random_widget_monkey_zero_random_click_prob_rewards, axis=0)"
8388
]
8489
},
@@ -93,13 +98,13 @@
9398
"second_controller_rewards = []\n",
9499
"\n",
95100
"\n",
96-
"first_controller_rewards.append(np.load(first_controller_model_file)[\"all_rewards\"])\n",
97-
"second_controller_rewards.append(np.load(second_controller_model_file)[\"all_rewards\"])\n",
101+
"first_controller_rewards = np.load(first_controller_model_file)[\"all_rewards\"]\n",
102+
"second_controller_rewards = np.load(second_controller_model_file)[\"all_rewards\"]\n",
98103
"\n",
99104
"first_controller_mean = np.mean(first_controller_rewards, axis=0)\n",
100105
"second_controller_mean = np.mean(second_controller_rewards, axis=0)\n",
101106
"\n",
102-
"controller_mean = np.mean([first_controller_mean, second_controller_mean], axis=0)\n",
107+
"controller_mean = np.mean([first_controller_mean, second_controller_mean], axis=0).cumsum()\n",
103108
"controller_std = np.std([first_controller_mean, second_controller_mean], axis=0)"
104109
]
105110
},
@@ -112,36 +117,34 @@
112117
"source": [
113118
"data_length_x = random_monkey_mean.shape\n",
114119
"\n",
115-
"assert data_length_x = random_monkey_std.shape\n",
116-
"assert data_length_x = random_widget_monkey_mean.shape\n",
117-
"assert data_length_x = random_widget_monkey_std.shape\n",
118-
"assert data_length_x = random_widget_monkey_zero_random_click_prob_mean.shape\n",
119-
"assert data_length_x = random_widget_monkey_zero_random_click_prob_std.shape\n",
120-
"\n",
121-
"assert data_length_x = controller_mean.shape\n",
122-
"assert data_length_x = random_monkey_std.shape\n",
120+
"assert data_length_x == random_monkey_std.shape\n",
121+
"assert data_length_x == random_widget_monkey_mean.shape\n",
122+
"assert data_length_x == random_widget_monkey_std.shape\n",
123+
"assert data_length_x == random_widget_monkey_zero_random_click_prob_mean.shape\n",
124+
"assert data_length_x == random_widget_monkey_zero_random_click_prob_std.shape\n",
123125
"\n",
124-
"x_values = np.arange(data_length_x[0])\n",
126+
"assert data_length_x == controller_mean.shape\n",
127+
"assert data_length_x == random_monkey_std.shape\n",
125128
"\n",
126129
"fig, ax = plt.subplots()\n",
130+
"x_data = np.arange(data_length_x[0])\n",
127131
"\n",
128-
"ax.plot(x_values, random_monkey_mean, label=\"Random Monkey Tester\")\n",
129-
"ax.fill_between(x_values, random_monkey_mean - random_monkey_std, random_monkey_mean + random_monkey_std, alpha=0.25)\n",
132+
"ax.plot(x_data, random_monkey_mean, label=\"Random Monkey Tester\")\n",
133+
"ax.fill_between(x_data, random_monkey_mean - random_monkey_std, random_monkey_mean + random_monkey_std, alpha=0.25)\n",
130134
"\n",
131-
"ax.plot(x_values, random_widget_monkey_mean, label=\"Random Widget Monkey Tester\")\n",
132-
"ax.fill_between(x_values, random_widget_monkey_mean - random_widget_monkey_std, random_widget_monkey_mean + random_widget_monkey_std, alpha=0.25)\n",
135+
"ax.plot(x_data, random_widget_monkey_mean, label=\"Random Widget Monkey Tester (0.125)\")\n",
136+
"ax.fill_between(x_data, random_widget_monkey_mean - random_widget_monkey_std, random_widget_monkey_mean + random_widget_monkey_std, alpha=0.25)\n",
133137
"\n",
134-
"ax.plot(x_values, random_widget_monkey_zero_random_click_prob_mean, label=\"Random Widget Monkey Tester (0.0)\")\n",
135-
"ax.fill_between(x_values,\n",
136-
" random_widget_monkey_zero_random_click_prob_mean - random_widget_monkey_zero_random_click_prob_std,\n",
138+
"ax.plot(x_data, random_widget_monkey_zero_random_click_prob_mean, label=\"Random Widget Monkey Tester (0.0)\")\n",
139+
"ax.fill_between(x_data, random_widget_monkey_zero_random_click_prob_mean - random_widget_monkey_zero_random_click_prob_std,\n",
137140
" random_widget_monkey_zero_random_click_prob_mean + random_widget_monkey_zero_random_click_prob_std,\n",
138141
" alpha=0.25)\n",
139142
"\n",
140-
"ax.plot(x_values, controller_mean, label=\"Best Approach\")\n",
141-
"ax.fill_between(x_values, controller_mean - controller_std, controller_mean + controller_std, alpha=0.25)\n",
143+
"ax.plot(x_data, controller_mean, label=\"Investigated Approach (v_275, m_187)\")\n",
144+
"ax.fill_between(x_data, controller_mean - controller_std, controller_mean + controller_std, alpha=0.25)\n",
142145
"\n",
143-
"ax.set(ylabel=\"Code Coverage (\\%)\", xlabel='Time Steps')\n",
144-
"ax.legend(loc='upper left')\n",
146+
"ax.set(ylabel=\"Code Coverage (%)\", xlabel='Time Steps')\n",
147+
"ax.legend(loc='lower right')\n",
145148
"\n",
146149
"fig.savefig(\"c_model_comparison_monkey_tester.pdf\", bbox_inches='tight')\n",
147150
"plt.show()"
@@ -150,7 +153,7 @@
150153
],
151154
"metadata": {
152155
"kernelspec": {
153-
"display_name": "Python 3",
156+
"display_name": "Python 3 (ipykernel)",
154157
"language": "python",
155158
"name": "python3"
156159
},
@@ -164,7 +167,7 @@
164167
"name": "python",
165168
"nbconvert_exporter": "python",
166169
"pygments_lexer": "ipython3",
167-
"version": "3.8.8"
170+
"version": "3.9.6"
168171
}
169172
},
170173
"nbformat": 4,

0 commit comments

Comments
 (0)