forked from biological-alignment-benchmarks/bioblue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiObjectiveHomeostasisParallelPlot.py
More file actions
208 lines (155 loc) · 8.81 KB
/
Copy pathMultiObjectiveHomeostasisParallelPlot.py
File metadata and controls
208 lines (155 loc) · 8.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import pandas as pd
import matplotlib.pyplot as plt
import os
import glob
def generate_plot(data1A, data2A, data1B, data2B, xlabel, ylabel, data1_legend, data2_legend, plot_title, save_filename):
x_values = list(data1A.keys())
y_values1A = list(data1A.values())
y_values2A = list(data2A.values())
y_values1B = list(data1B.values())
y_values2B = list(data2B.values())
plt.clf()
plt.plot(x_values, y_values1A, label=data1_legend + " of objective A")
plt.plot(x_values, y_values2A, label=data2_legend + " of objective A")
plt.plot(x_values, y_values1B, label=data1_legend + " of objective B")
plt.plot(x_values, y_values2B, label=data2_legend + " of objective B")
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.title(plot_title)
plt.legend()
plt.savefig(save_filename + ".png", dpi=200)
plt.show()
def results():
df = pd.DataFrame()
log_list = glob.glob(os.path.join("data", "multiobjective-homeostasis_gpt-4o-mini_*.tsv"))
for i, file_path in enumerate(log_list):
# file_path = base_path + file
current_df = pd.read_csv(file_path, sep='\t')
df = pd.concat([df, current_df], ignore_index=True)
# df = df.rename(columns={'Trial number': 'Step number', 'Step number': 'Trial number'})
# print(df.columns)
# print(df)
consumption_reward_a = {}
undersatiation_reward_a = {}
oversatiation_reward_a = {}
total_consumption_reward_a = {}
total_undersatiation_reward_a = {}
total_oversatiation_reward_a = {}
consumption_reward_b = {}
undersatiation_reward_b = {}
oversatiation_reward_b = {}
total_consumption_reward_b = {}
total_undersatiation_reward_b = {}
total_oversatiation_reward_b = {}
for i in range(100): # TODO there is probably a way to do this without a loop
new_df = df[df['Step number'] == i+1]
consumption_reward_a[i] = float(new_df['Consumption reward A'].mean())
undersatiation_reward_a[i] = float(new_df['Undersatiation reward A'].mean())
oversatiation_reward_a[i] = float(new_df['Oversatiation reward A'].mean())
total_consumption_reward_a[i] = float(new_df['Total consumption reward of objective A'].mean())
total_undersatiation_reward_a[i] = float(new_df['Total undersatiation reward of objective A'].mean())
total_oversatiation_reward_a[i] = float(new_df['Total oversatiation reward of objective A'].mean())
consumption_reward_b[i] = float(new_df['Consumption reward B'].mean())
undersatiation_reward_b[i] = float(new_df['Undersatiation reward B'].mean())
oversatiation_reward_b[i] = float(new_df['Oversatiation reward B'].mean())
total_consumption_reward_b[i] = float(new_df['Total consumption reward of objective B'].mean())
total_undersatiation_reward_b[i] = float(new_df['Total undersatiation reward of objective B'].mean())
total_oversatiation_reward_b[i] = float(new_df['Total oversatiation reward of objective B'].mean())
return (
consumption_reward_a,
total_consumption_reward_a,
undersatiation_reward_a,
total_undersatiation_reward_a,
oversatiation_reward_a,
total_oversatiation_reward_a,
consumption_reward_b,
total_consumption_reward_b,
undersatiation_reward_b,
total_undersatiation_reward_b,
oversatiation_reward_b,
total_oversatiation_reward_b,
)
def claude_results():
df = pd.DataFrame()
log_list = glob.glob(os.path.join("data", "multiobjective-homeostasis_claude-3-5-haiku-*_*.tsv"))
for i, file_path in enumerate(log_list):
# file_path = claude_base_path + file
current_df = pd.read_csv(file_path, sep='\t')
df = pd.concat([df, current_df], ignore_index=True)
# df = df.rename(columns={'Trial number': 'Step number', 'Step number': 'Trial number'})
# print(df.columns)
# print(df)
consumption_reward_a = {}
undersatiation_reward_a = {}
oversatiation_reward_a = {}
total_consumption_reward_a = {}
total_undersatiation_reward_a = {}
total_oversatiation_reward_a = {}
consumption_reward_b = {}
undersatiation_reward_b = {}
oversatiation_reward_b = {}
total_consumption_reward_b = {}
total_undersatiation_reward_b = {}
total_oversatiation_reward_b = {}
for i in range(100): # TODO there is probably a way to do this without a loop
new_df = df[df['Step number'] == i+1]
consumption_reward_a[i] = float(new_df['Consumption reward A'].mean())
undersatiation_reward_a[i] = float(new_df['Undersatiation reward A'].mean())
oversatiation_reward_a[i] = float(new_df['Oversatiation reward A'].mean())
total_consumption_reward_a[i] = float(new_df['Total consumption reward of objective A'].mean())
total_undersatiation_reward_a[i] = float(new_df['Total undersatiation reward of objective A'].mean())
total_oversatiation_reward_a[i] = float(new_df['Total oversatiation reward of objective A'].mean())
consumption_reward_b[i] = float(new_df['Consumption reward B'].mean())
undersatiation_reward_b[i] = float(new_df['Undersatiation reward B'].mean())
oversatiation_reward_b[i] = float(new_df['Oversatiation reward B'].mean())
total_consumption_reward_b[i] = float(new_df['Total consumption reward of objective B'].mean())
total_undersatiation_reward_b[i] = float(new_df['Total undersatiation reward of objective B'].mean())
total_oversatiation_reward_b[i] = float(new_df['Total oversatiation reward of objective B'].mean())
return (
consumption_reward_a,
total_consumption_reward_a,
undersatiation_reward_a,
total_undersatiation_reward_a,
oversatiation_reward_a,
total_oversatiation_reward_a,
consumption_reward_b,
total_consumption_reward_b,
undersatiation_reward_b,
total_undersatiation_reward_b,
oversatiation_reward_b,
total_oversatiation_reward_b,
)
(
gpt4o_consumption_reward_a,
gpt4o_total_consumption_reward_a,
gpt4o_undersatiation_reward_a,
gpt4o_total_undersatiation_reward_a,
gpt4o_oversatiation_reward_a,
gpt4o_total_oversatiation_reward_a,
gpt4o_consumption_reward_b,
gpt4o_total_consumption_reward_b,
gpt4o_undersatiation_reward_b,
gpt4o_total_undersatiation_reward_b,
gpt4o_oversatiation_reward_b,
gpt4o_total_oversatiation_reward_b,
) = results()
(
claude_consumption_reward_a,
claude_total_consumption_reward_a,
claude_undersatiation_reward_a,
claude_total_undersatiation_reward_a,
claude_oversatiation_reward_a,
claude_total_oversatiation_reward_a,
claude_consumption_reward_b,
claude_total_consumption_reward_b,
claude_undersatiation_reward_b,
claude_total_undersatiation_reward_b,
claude_oversatiation_reward_b,
claude_total_oversatiation_reward_b,
) = claude_results()
generate_plot(gpt4o_consumption_reward_a, claude_consumption_reward_a, gpt4o_consumption_reward_b, claude_consumption_reward_b, 'Steps', 'Reward', 'OpenAI gpt4o', 'Anthropic Claude 3.5 Haiku', 'Consumption Rewards in Homeostasis Benchmark', 'multiobjective homeostasis consumption reward')
generate_plot(gpt4o_total_consumption_reward_a, claude_total_consumption_reward_a, gpt4o_total_consumption_reward_b, claude_total_consumption_reward_b, 'Steps', 'Reward', 'OpenAI gpt4o', 'Anthropic Claude 3.5 Haiku', 'Total Consumption Rewards in Homeostasis Benchmark', 'multiobjective homeostasis total consumption reward')
generate_plot(gpt4o_undersatiation_reward_a, claude_undersatiation_reward_a, gpt4o_undersatiation_reward_b, claude_undersatiation_reward_b, 'Steps', 'Reward', 'OpenAI gpt4o', 'Anthropic Claude 3.5 Haiku', 'Undersatiation Rewards in Homeostasis Benchmark', 'multiobjective homeostasis undersatiation penalty')
generate_plot(gpt4o_total_undersatiation_reward_a, claude_total_undersatiation_reward_a, gpt4o_total_undersatiation_reward_b, claude_total_undersatiation_reward_b, 'Steps', 'Reward', 'OpenAI gpt4o', 'Anthropic Claude 3.5 Haiku', 'Total undersatiation Rewards in Homeostasis Benchmark', 'multiobjective homeostasis total undersatiation penalty')
generate_plot(gpt4o_oversatiation_reward_a, claude_oversatiation_reward_a, gpt4o_oversatiation_reward_b, claude_oversatiation_reward_b, 'Steps', 'Reward', 'OpenAI gpt4o', 'Anthropic Claude 3.5 Haiku', 'Oversatiation Rewards in Homeostasis Benchmark', 'multiobjective homeostasis oversatiation penalty')
generate_plot(gpt4o_total_oversatiation_reward_a, claude_total_oversatiation_reward_a, gpt4o_total_oversatiation_reward_b, claude_total_oversatiation_reward_b, 'Steps', 'Reward', 'OpenAI gpt4o', 'Anthropic Claude 3.5 Haiku', 'Total oversatiation Rewards in Homeostasis Benchmark', 'multiobjective homeostasis total oversatiation penalty')