(trials, do_show=True, status_colors=None, title="Loss History")
| 34 | |
| 35 | |
| 36 | def main_plot_history(trials, do_show=True, status_colors=None, title="Loss History"): |
| 37 | # -- import here because file-level import is too early |
| 38 | import matplotlib.pyplot as plt |
| 39 | |
| 40 | # self is an Experiment |
| 41 | if status_colors is None: |
| 42 | status_colors = default_status_colors |
| 43 | |
| 44 | # XXX: show the un-finished or error trials |
| 45 | Ys, colors = zip( |
| 46 | *[ |
| 47 | (y, status_colors[s]) |
| 48 | for y, s in zip(trials.losses(), trials.statuses()) |
| 49 | if y is not None |
| 50 | ] |
| 51 | ) |
| 52 | plt.scatter(range(len(Ys)), Ys, c=colors) |
| 53 | plt.xlabel("time") |
| 54 | plt.ylabel("loss") |
| 55 | |
| 56 | best_err = trials.average_best_error() |
| 57 | print("avg best error:", best_err) |
| 58 | plt.axhline(best_err, c="g") |
| 59 | |
| 60 | plt.title(title) |
| 61 | if do_show: |
| 62 | plt.show() |
| 63 | |
| 64 | |
| 65 | def main_plot_histogram(trials, do_show=True, title="Loss Histogram"): |
nothing calls this directly
no test coverage detected