def plot_evolution_happiness(evo_training, method_id, info_params, final=True): avg_happiness = get_avg_n_points(evo_training['evo_avg_happiness'], n_points=100) min_happiness = get_avg_n_points(evo_training['evo_min_happiness'], n_points=100) max_happiness = get_avg_n_points(evo_training['evo_max_happiness'], n_points=100) x = range(len(avg_happiness)) fig = plt.figure() plt.plot(x, avg_happiness) plt.plot(x, min_happiness, linestyle=':', color='lightcoral') plt.plot(x, max_happiness, linestyle=':', color='lightgreen') plt.title('Min/Avg/Max Happiness over time (smoothed)') plt.ylim([-0.05, 1.05]) plt.xlabel('Episode (percentile) \n ' + info_params) plt.ylabel('Min/Avg/Max Happiness (smoothed)') plt.grid(True) plt.tight_layout() plt.savefig(get_directory_figures(final) + '{}__happiness.png'.format(method_id), format='png', dpi=500) # plt.show() plt.close(fig)
def plot_evolution_steps(evo_training, method_id, nmax_steps, info_params, final=True): fig = plt.figure() avg_steps = get_avg_n_points(evo_training['evo_n_steps'], n_points=100) x = range(len(avg_steps)) plt.plot(x, avg_steps) min_steps = get_min_n_points(evo_training['evo_n_steps'], n_points=min(100, len(evo_training['evo_n_steps']))) x = range(len(min_steps)) plt.plot(x, min_steps, linestyle=':', color='lightcoral') max_steps = get_max_n_points(evo_training['evo_n_steps'], n_points=min(100, len(evo_training['evo_n_steps']))) x = range(len(max_steps)) plt.plot(x, max_steps, linestyle=':', color='lightgreen') plt.title('Episode Length over time (smoothed)') plt.axhline(nmax_steps, color='r') plt.axhline(0, color='b') plt.ylim([-10, nmax_steps * 1.05]) plt.xlabel('Episode (percentile) \n ' + info_params) plt.ylabel('Episode Length (smoothed)') plt.grid(True) plt.tight_layout() plt.savefig(get_directory_figures(final) + '{}__steps.png'.format(method_id), format='png', dpi=500) # plt.show() plt.close(fig)
def plot_evolution_reward(evo_training, method_id, info_params, final=True): avg_reward = get_avg_n_points(evo_training['evo_avg_reward_per_step'], n_points=100) min_reward = get_avg_n_points(evo_training['evo_min_reward_per_step'], n_points=100) max_reward = get_avg_n_points(evo_training['evo_max_reward_per_step'], n_points=100) x = range(len(avg_reward)) fig = plt.figure() plt.plot(x, avg_reward) plt.plot(x, min_reward, linestyle=':', color='lightcoral') plt.plot(x, max_reward, linestyle=':', color='lightgreen') plt.title('Evolution of Min/Avg/Max Reward \n per step per episode over time (smoothed)') plt.xlabel('Episode (percentile) \n ' + info_params) plt.ylabel('Min/Avg/Max Reward \n per step per episode (smoothed)') plt.grid(True) plt.tight_layout() plt.savefig(get_directory_figures(final) + '{}__reward.png'.format(method_id), format='png', dpi=500) # plt.show() plt.close(fig)
def plot_alpha(evo_alpha, method_id, info_params, final=True): y = get_avg_n_points(evo_alpha, n_points=100) x = range(len(y)) fig = plt.figure() plt.plot(x, y) plt.yscale('log') plt.title('Alpha') plt.xlabel('Episode (percentile) \n ' + info_params) plt.ylabel('Alpha (log scale)') plt.grid(True) plt.tight_layout() plt.savefig(get_directory_figures(final) + '{}__alpha.png'.format(method_id), format='png', dpi=500) # plt.show() plt.close(fig)
def plot_comparison_evolution_steps(evo_training__evo_n_steps, nmax_steps, info_params): fig = plt.figure() cnt = 0 for method in list(evo_training__evo_n_steps.keys()): y = get_avg_n_points(evo_training__evo_n_steps[method], n_points=100) x = range(len(y)) plt.plot(x, y, label=method, marker='', color=COLORS[cnt], linewidth=1, alpha=0.75) cnt += 1 plt.title('Episode Length over time (smoothed)') plt.axhline(nmax_steps, color='r') plt.axhline(0, color='b') plt.ylim([-10, nmax_steps * 1.05]) plt.xlabel('Episode (percentile) \n ' + info_params) plt.ylabel('Episode Length (Smoothed)') plt.legend(bbox_to_anchor=(0.5, -0.10), loc="lower center", bbox_transform=fig.transFigure, ncol=4, fancybox=True, shadow=True, borderpad=1) plt.grid(True) plt.tight_layout() plt.savefig('data/figures/Comparison__steps.png', format='png', dpi=1000, bbox_inches='tight') # plt.show() plt.close(fig)