mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-23 15:26:43 +02:00
adjusted combine_runs
This commit is contained in:
parent
c798226b26
commit
017a94d6b7
@ -30,11 +30,11 @@ def prepare_plot(filepath, results_df, ext='png'):
|
|||||||
results_df.Measurement = results_df.Measurement.str.replace('_', '-')
|
results_df.Measurement = results_df.Measurement.str.replace('_', '-')
|
||||||
try:
|
try:
|
||||||
sns.set(rc={'text.usetex': True}, style='whitegrid')
|
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!
|
plot(filepath, ext=ext) # plot raises errors not lineplot!
|
||||||
except (FileNotFoundError, RuntimeError):
|
except (FileNotFoundError, RuntimeError):
|
||||||
print('Struggling to plot Figure using LaTeX - going back to normal.')
|
print('Struggling to plot Figure using LaTeX - going back to normal.')
|
||||||
plt.close('all')
|
plt.close('all')
|
||||||
sns.set(rc={'text.usetex': False}, style='whitegrid')
|
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)
|
plot(filepath, ext=ext)
|
||||||
|
10
main.py
10
main.py
@ -32,13 +32,17 @@ def combine_runs(run_path: Union[str, PathLike]):
|
|||||||
df = df.fillna(0).rename(columns={'episode': 'Episode', 'run': 'Run'})
|
df = df.fillna(0).rename(columns={'episode': 'Episode', 'run': 'Run'})
|
||||||
columns = [col for col in df.columns if col not in IGNORED_DF_COLUMNS]
|
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'],
|
df_melted = non_overlapp_window[columns].reset_index().melt(id_vars=['Episode', 'Run'],
|
||||||
value_vars=columns, var_name="Measurement",
|
value_vars=columns, var_name="Measurement",
|
||||||
value_name="Score")
|
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)
|
prepare_plot(run_path / f'{run_path.name}_monitor_lineplot.png', df_melted)
|
||||||
print('Plotting done.')
|
print('Plotting done.')
|
||||||
@ -51,8 +55,6 @@ if __name__ == '__main__':
|
|||||||
time_stamp = int(time.time())
|
time_stamp = int(time.time())
|
||||||
|
|
||||||
out_path = None
|
out_path = None
|
||||||
combine_runs(Path('/Users/romue/PycharmProjects/EDYS/debug_out/A2C_1622571986'))
|
|
||||||
exit()
|
|
||||||
|
|
||||||
for modeL_type in [A2C, PPO, DQN]:
|
for modeL_type in [A2C, PPO, DQN]:
|
||||||
for seed in range(5):
|
for seed in range(5):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user