|
8 | 8 | "outputs": [],
|
9 | 9 | "source": [
|
10 | 10 | "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(\"../\")" |
12 | 15 | ]
|
13 | 16 | },
|
14 | 17 | {
|
15 | 18 | "cell_type": "markdown",
|
16 | 19 | "id": "a373b877-d487-4ccf-afd8-cefa968d8a0f",
|
17 |
| - "metadata": {}, |
| 20 | + "metadata": { |
| 21 | + "tags": [] |
| 22 | + }, |
18 | 23 | "source": [
|
19 | 24 | "# Plot of three monkey testers compared with the Approach\n",
|
20 | 25 | "\n",
|
|
33 | 38 | "metadata": {},
|
34 | 39 | "outputs": [],
|
35 | 40 | "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", |
39 | 44 | "\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\"" |
42 | 47 | ]
|
43 | 48 | },
|
44 | 49 | {
|
|
52 | 57 | "random_widget_monkey_rewards = []\n",
|
53 | 58 | "random_widget_monkey_zero_random_click_prob_rewards = []\n",
|
54 | 59 | "\n",
|
55 |
| - "for monkey_dir in monkey_tester_dirs:\n", |
| 60 | + "for i in range(3):\n", |
56 | 61 | " \n",
|
57 | 62 | " if i == 0:\n",
|
58 | 63 | " monkey_dir = random_monkey_dir\n",
|
|
72 | 77 | " sequence_data = np.load(os.path.join(monkey_dir, seq_dir, \"data.npz\"))\n",
|
73 | 78 | " reward_list.append(sequence_data[\"rewards\"])\n",
|
74 | 79 | " \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", |
76 | 81 | "random_monkey_std = np.std(random_monkey_rewards, axis=0)\n",
|
77 | 82 | "\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", |
79 | 84 | "random_widget_monkey_std = np.std(random_widget_monkey_rewards, axis=0)\n",
|
80 | 85 | "\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", |
82 | 87 | "random_widget_monkey_zero_random_click_prob_std = np.std(random_widget_monkey_zero_random_click_prob_rewards, axis=0)"
|
83 | 88 | ]
|
84 | 89 | },
|
|
93 | 98 | "second_controller_rewards = []\n",
|
94 | 99 | "\n",
|
95 | 100 | "\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", |
98 | 103 | "\n",
|
99 | 104 | "first_controller_mean = np.mean(first_controller_rewards, axis=0)\n",
|
100 | 105 | "second_controller_mean = np.mean(second_controller_rewards, axis=0)\n",
|
101 | 106 | "\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", |
103 | 108 | "controller_std = np.std([first_controller_mean, second_controller_mean], axis=0)"
|
104 | 109 | ]
|
105 | 110 | },
|
|
112 | 117 | "source": [
|
113 | 118 | "data_length_x = random_monkey_mean.shape\n",
|
114 | 119 | "\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", |
123 | 125 | "\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", |
125 | 128 | "\n",
|
126 | 129 | "fig, ax = plt.subplots()\n",
|
| 130 | + "x_data = np.arange(data_length_x[0])\n", |
127 | 131 | "\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", |
130 | 134 | "\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", |
133 | 137 | "\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", |
137 | 140 | " random_widget_monkey_zero_random_click_prob_mean + random_widget_monkey_zero_random_click_prob_std,\n",
|
138 | 141 | " alpha=0.25)\n",
|
139 | 142 | "\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", |
142 | 145 | "\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", |
145 | 148 | "\n",
|
146 | 149 | "fig.savefig(\"c_model_comparison_monkey_tester.pdf\", bbox_inches='tight')\n",
|
147 | 150 | "plt.show()"
|
|
150 | 153 | ],
|
151 | 154 | "metadata": {
|
152 | 155 | "kernelspec": {
|
153 |
| - "display_name": "Python 3", |
| 156 | + "display_name": "Python 3 (ipykernel)", |
154 | 157 | "language": "python",
|
155 | 158 | "name": "python3"
|
156 | 159 | },
|
|
164 | 167 | "name": "python",
|
165 | 168 | "nbconvert_exporter": "python",
|
166 | 169 | "pygments_lexer": "ipython3",
|
167 |
| - "version": "3.8.8" |
| 170 | + "version": "3.9.6" |
168 | 171 | }
|
169 | 172 | },
|
170 | 173 | "nbformat": 4,
|
|
0 commit comments