| 474 | |
| 475 | |
| 476 | def plot_evolve(evolve_csv='path/to/evolve.csv'): # from utils.plots import *; plot_evolve() |
| 477 | # Plot evolve.csv hyp evolution results |
| 478 | evolve_csv = Path(evolve_csv) |
| 479 | data = pd.read_csv(evolve_csv) |
| 480 | keys = [x.strip() for x in data.columns] |
| 481 | x = data.values |
| 482 | f = fitness(x) |
| 483 | j = np.argmax(f) # max fitness index |
| 484 | plt.figure(figsize=(10, 12), tight_layout=True) |
| 485 | matplotlib.rc('font', **{'size': 8}) |
| 486 | print(f'Best results from row {j} of {evolve_csv}:') |
| 487 | for i, k in enumerate(keys[7:]): |
| 488 | v = x[:, 7 + i] |
| 489 | mu = v[j] # best single result |
| 490 | plt.subplot(6, 5, i + 1) |
| 491 | plt.scatter(v, f, c=hist2d(v, f, 20), cmap='viridis', alpha=.8, edgecolors='none') |
| 492 | plt.plot(mu, f.max(), 'k+', markersize=15) |
| 493 | plt.title(f'{k} = {mu:.3g}', fontdict={'size': 9}) # limit to 40 characters |
| 494 | if i % 5 != 0: |
| 495 | plt.yticks([]) |
| 496 | print(f'{k:>15}: {mu:.3g}') |
| 497 | f = evolve_csv.with_suffix('.png') # filename |
| 498 | plt.savefig(f, dpi=200) |
| 499 | plt.close() |
| 500 | print(f'Saved {f}') |
| 501 | |
| 502 | |
| 503 | def plot_results(file='path/to/results.csv', dir=''): |