adjusted combine_runs

This commit is contained in:
romue 2021-06-02 12:54:33 +02:00
parent c798226b26
commit 017a94d6b7
2 changed files with 8 additions and 6 deletions

View File

@ -30,11 +30,11 @@ def prepare_plot(filepath, results_df, ext='png'):
results_df.Measurement = results_df.Measurement.str.replace('_', '-')
try:
sns.set(rc={'text.usetex': True}, style='whitegrid')
sns.lineplot(data=results_df, x='Episode', y='Score', hue='Measurement', ci='sd', palette=PALETTE)
sns.lineplot(data=results_df, x='Episode', y='Score', hue='Measurement', ci=95, palette=PALETTE)
plot(filepath, ext=ext) # plot raises errors not lineplot!
except (FileNotFoundError, RuntimeError):
print('Struggling to plot Figure using LaTeX - going back to normal.')
plt.close('all')
sns.set(rc={'text.usetex': False}, style='whitegrid')
sns.lineplot(data=results_df, x='Episode', y='Score', hue='Measurement', ci='sd', palette=PALETTE)
sns.lineplot(data=results_df, x='Episode', y='Score', hue='Measurement', ci=95, palette=PALETTE)
plot(filepath, ext=ext)

10
main.py
View File

@ -32,13 +32,17 @@ def combine_runs(run_path: Union[str, PathLike]):
df = df.fillna(0).rename(columns={'episode': 'Episode', 'run': 'Run'})
columns = [col for col in df.columns if col not in IGNORED_DF_COLUMNS]
print(df.head())
roll_n = 30
skip_n = 20
non_overlapp_window = df.groupby(['Run', df['Episode'] // 20]).mean()
non_overlapp_window = df.groupby(['Run', 'Episode']).rolling(roll_n, min_periods=1).mean()
df_melted = non_overlapp_window[columns].reset_index().melt(id_vars=['Episode', 'Run'],
value_vars=columns, var_name="Measurement",
value_name="Score")
df_melted = df_melted[df_melted['Episode'] % skip_n == 0]
#df_melted['Episode'] = df_melted['Episode'] * skip_n # only needed for old version
prepare_plot(run_path / f'{run_path.name}_monitor_lineplot.png', df_melted)
print('Plotting done.')
@ -51,8 +55,6 @@ if __name__ == '__main__':
time_stamp = int(time.time())
out_path = None
combine_runs(Path('/Users/romue/PycharmProjects/EDYS/debug_out/A2C_1622571986'))
exit()
for modeL_type in [A2C, PPO, DQN]:
for seed in range(5):