| 241 | |
| 242 | |
| 243 | def interactive_HBS_plot(learning_curves, tool_tip_strings=None,log_y=False, log_x=False, reset_times=False, color_map='Set3', colors_floats=None, title='', show=True): |
| 244 | |
| 245 | times, losses, config_ids, = [], [], [] |
| 246 | |
| 247 | for k,v in learning_curves.items(): |
| 248 | for l in v: |
| 249 | if len(l) == 0: continue |
| 250 | tmp = list(zip(*l)) |
| 251 | try: |
| 252 | times.append(tmp[0]) |
| 253 | losses.append(tmp[1]) |
| 254 | config_ids.append(k) |
| 255 | except: |
| 256 | import pdb; pdb.set_trace() |
| 257 | |
| 258 | |
| 259 | |
| 260 | num_curves = len(times) |
| 261 | HB_iterations = [id[0] for id in config_ids] |
| 262 | |
| 263 | num_iterations = len(set(HB_iterations)) |
| 264 | |
| 265 | cmap = plt.get_cmap(color_map) |
| 266 | |
| 267 | |
| 268 | |
| 269 | if reset_times: |
| 270 | times = [np.array(ts) - ts[0] for ts in times] |
| 271 | |
| 272 | |
| 273 | if colors_floats is None: |
| 274 | color_floats = [] |
| 275 | for i in range(num_curves): |
| 276 | seed = 100*np.abs(config_ids[i][0]) + 10*config_ids[i][1] + config_ids[i][2] |
| 277 | np.random.seed(seed) |
| 278 | color_floats.append(np.random.rand()) |
| 279 | |
| 280 | fig, ax = plt.subplots() |
| 281 | |
| 282 | lines = [[] for i in range(num_iterations)] |
| 283 | |
| 284 | iteration_labels = list(range(num_iterations)) |
| 285 | if HB_iterations[-1] == -1: |
| 286 | iteration_labels[-1] = 'warmstart data' |
| 287 | |
| 288 | |
| 289 | |
| 290 | all_lines = [] |
| 291 | |
| 292 | for i in range(num_curves): |
| 293 | l, = ax.plot(times[i], losses[i], color=cmap(color_floats[i]), marker='o', gid=i, picker=True) |
| 294 | lines[HB_iterations[i]].append(l) |
| 295 | all_lines.append(l) |
| 296 | |
| 297 | if log_y: |
| 298 | plt.yscale('log') |
| 299 | |
| 300 | ax.set_title(title) |