-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinal_plots.py
150 lines (119 loc) · 9.59 KB
/
final_plots.py
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
import numpy as np
import os
import matplotlib.pyplot as plt
run_path='experiment1'
picture_path='figures/RBF_kernel_all_algos.png'
benchmark_avg_regrets_runs = np.load(f'{run_path}/Benchmark Model_RBF_0.1_80/avg_regrets_runs.npy')
benchmark_std_regrets_runs = np.load(f'{run_path}/Benchmark Model_RBF_0.1_80/std_regrets_runs.npy')
benchmark_avg_regrets_mean = np.mean(benchmark_avg_regrets_runs, axis=0)
benchmark_std_regrets_std = np.sqrt(np.mean(np.square(benchmark_std_regrets_runs), axis=0))
# Load max variance data
max_variance_avg_regrets_runs = np.load(f'{run_path}/Greedy Max Variance_RBF_0.1_80/avg_regrets_runs.npy')
max_variance_std_regrets_runs = np.load(f'{run_path}/Greedy Max Variance_RBF_0.1_80/std_regrets_runs.npy')
max_variance_avg_regrets_mean = np.mean(max_variance_avg_regrets_runs, axis=0)
max_variance_std_regrets_std = np.sqrt(np.mean(np.square(max_variance_std_regrets_runs), axis=0))
# Load max variance data 2
max_variance2_avg_regrets_runs = np.load(f'{run_path}/Without generative model_RBF_0.1_80/avg_regrets_runs.npy')
max_variance2_std_regrets_runs = np.load(f'{run_path}/Without generative model_RBF_0.1_80/std_regrets_runs.npy')
max_variance2_avg_regrets_mean = np.mean(max_variance2_avg_regrets_runs, axis=0)
max_variance2_std_regrets_std = np.sqrt(np.mean(np.square(max_variance2_std_regrets_runs), axis=0))
# Load generative model
generative_model_avg_regrets_runs = np.load(f'{run_path}/Generative model_RBF_0.1_80/avg_regrets_runs.npy')
generative_model_std_regrets_runs = np.load(f'{run_path}/Generative model_RBF_0.1_80/std_regrets_runs.npy')
generative_model_avg_regrets_mean = np.mean(generative_model_avg_regrets_runs, axis=0)
generative_model_std_regrets_std = np.sqrt(np.mean(np.square(generative_model_std_regrets_runs), axis=0))
episode_list=[10, 20, 40, 80, 160]
# Plot average regret with standard deviation for both models
plt.errorbar(episode_list, benchmark_avg_regrets_mean, yerr=benchmark_std_regrets_std, fmt='o',color='b')
plt.plot(episode_list, benchmark_avg_regrets_mean, linestyle='-', marker='o', color='b', label='(Qiu et al., 2021)') # Line connecting points
plt.errorbar(episode_list, max_variance_avg_regrets_mean, yerr=max_variance_std_regrets_std, fmt='o',color='r')
plt.plot(episode_list, max_variance_avg_regrets_mean, linestyle='-', marker='o', color='r', label='Greedy Max Variance') # Line connecting points
plt.errorbar(episode_list, max_variance2_avg_regrets_mean, yerr=max_variance2_std_regrets_std, fmt='o', color='g')
plt.plot(episode_list, max_variance2_avg_regrets_mean, linestyle='-', marker='o', color='g', label='Without generative model')
plt.errorbar(episode_list, generative_model_avg_regrets_mean, yerr=generative_model_std_regrets_std, fmt='o', color='purple')
plt.plot(episode_list, generative_model_avg_regrets_mean, linestyle='-', marker='o', color='purple', label='With generative model')
# Configure matplotlib to use LaTeX for text rendering
# plt.rcParams['text.usetex'] = True
# plt.rcParams['text.latex.preamble'] = r'\usepackage{{amsmath}}' # You can add more packages if needed
plt.xlabel(r'$N$',fontsize=20)
plt.ylabel(r'$V^{\star}(s) -V^{\pi}(s)$',fontsize=20)
# plt.title('Average Regret with Standard Deviation')
plt.legend()
plt.savefig(picture_path)
plt.close()
# #############################################################################
picture_path='figures/Matern1.5_all_algos.png'
benchmark_avg_regrets_runs = np.load(f'{run_path}/Benchmark Model_Matern_smoothness_1.5_0.1_80/avg_regrets_runs.npy')
benchmark_std_regrets_runs = np.load(f'{run_path}/Benchmark Model_Matern_smoothness_1.5_0.1_80/std_regrets_runs.npy')
benchmark_avg_regrets_mean = np.mean(benchmark_avg_regrets_runs, axis=0)
benchmark_std_regrets_std = np.sqrt(np.mean(np.square(benchmark_std_regrets_runs), axis=0))
# Load max variance data
max_variance_avg_regrets_runs = np.load(f'{run_path}/Greedy Max Variance_Matern_smoothness_1.5_0.1_80/avg_regrets_runs.npy')
max_variance_std_regrets_runs = np.load(f'{run_path}/Greedy Max Variance_Matern_smoothness_1.5_0.1_80/std_regrets_runs.npy')
max_variance_avg_regrets_mean = np.mean(max_variance_avg_regrets_runs, axis=0)
max_variance_std_regrets_std = np.sqrt(np.mean(np.square(max_variance_std_regrets_runs), axis=0))
# Load max variance data 2
max_variance2_avg_regrets_runs = np.load(f'{run_path}/Without generative model_Matern_smoothness_1.5_0.1_80/avg_regrets_runs.npy')
max_variance2_std_regrets_runs = np.load(f'{run_path}/Without generative model_Matern_smoothness_1.5_0.1_80/std_regrets_runs.npy')
max_variance2_avg_regrets_mean = np.mean(max_variance2_avg_regrets_runs, axis=0)
max_variance2_std_regrets_std = np.sqrt(np.mean(np.square(max_variance2_std_regrets_runs), axis=0))
# Load generative model
generative_model_avg_regrets_runs = np.load(f'{run_path}/Generative model_Matern_smoothness_1.5_0.1_80/avg_regrets_runs.npy')
generative_model_std_regrets_runs = np.load(f'{run_path}/Generative model_Matern_smoothness_1.5_0.1_80/std_regrets_runs.npy')
generative_model_avg_regrets_mean = np.mean(generative_model_avg_regrets_runs, axis=0)
generative_model_std_regrets_std = np.sqrt(np.mean(np.square(generative_model_std_regrets_runs), axis=0))
episode_list=[10, 20, 40, 80, 160]
# Plot average regret with standard deviation for both models
plt.errorbar(episode_list, benchmark_avg_regrets_mean, yerr=benchmark_std_regrets_std, fmt='o',color='b')
plt.plot(episode_list, benchmark_avg_regrets_mean, linestyle='-', marker='o', color='b', label='(Qiu et al., 2021)') # Line connecting points
plt.errorbar(episode_list, max_variance_avg_regrets_mean, yerr=max_variance_std_regrets_std, fmt='o',color='r')
plt.plot(episode_list, max_variance_avg_regrets_mean, linestyle='-', marker='o', color='r', label='Greedy Max Variance') # Line connecting points
plt.errorbar(episode_list, max_variance2_avg_regrets_mean, yerr=max_variance2_std_regrets_std, fmt='o', color='g')
plt.plot(episode_list, max_variance2_avg_regrets_mean, linestyle='-', marker='o', color='g', label='Without generative model')
plt.errorbar(episode_list, generative_model_avg_regrets_mean, yerr=generative_model_std_regrets_std, fmt='o', color='purple')
plt.plot(episode_list, generative_model_avg_regrets_mean, linestyle='-', marker='o', color='purple', label='With generative model')
plt.xlabel(r'$N$',fontsize=20)
plt.ylabel(r'$V^{\star}(s) -V^{\pi}(s)$',fontsize=20)
# plt.title('Average Regret with Standard Deviation')
#plt.legend()
# Adjust the legend position to be at the bottom and center with a larger bounding box
plt.legend()
plt.savefig(picture_path)
plt.close()
# #######################################################################
picture_path='figures/Matern2.5_all_algos.png'
benchmark_avg_regrets_runs = np.load(f'{run_path}/Benchmark Model_Matern_smoothness_2.5_0.1_80/avg_regrets_runs.npy')
benchmark_std_regrets_runs = np.load(f'{run_path}/Benchmark Model_Matern_smoothness_2.5_0.1_80/std_regrets_runs.npy')
benchmark_avg_regrets_mean = np.mean(benchmark_avg_regrets_runs, axis=0)
benchmark_std_regrets_std = np.sqrt(np.mean(np.square(benchmark_std_regrets_runs), axis=0))
# Load max variance data
max_variance_avg_regrets_runs = np.load(f'{run_path}/Greedy Max Variance_Matern_smoothness_2.5_0.1_80/avg_regrets_runs.npy')
max_variance_std_regrets_runs = np.load(f'{run_path}/Greedy Max Variance_Matern_smoothness_2.5_0.1_80/std_regrets_runs.npy')
max_variance_avg_regrets_mean = np.mean(max_variance_avg_regrets_runs, axis=0)
max_variance_std_regrets_std = np.sqrt(np.mean(np.square(max_variance_std_regrets_runs), axis=0))
# Load max variance data 2
max_variance2_avg_regrets_runs = np.load(f'{run_path}/Without generative model_Matern_smoothness_2.5_0.1_80/avg_regrets_runs.npy')
max_variance2_std_regrets_runs = np.load(f'{run_path}/Without generative model_Matern_smoothness_2.5_0.1_80/std_regrets_runs.npy')
max_variance2_avg_regrets_mean = np.mean(max_variance2_avg_regrets_runs, axis=0)
max_variance2_std_regrets_std = np.sqrt(np.mean(np.square(max_variance2_std_regrets_runs), axis=0))
# Load generative model
generative_model_avg_regrets_runs = np.load(f'{run_path}/Generative model_Matern_smoothness_2.5_0.1_80/avg_regrets_runs.npy')
generative_model_std_regrets_runs = np.load(f'{run_path}/Generative model_Matern_smoothness_2.5_0.1_80/std_regrets_runs.npy')
generative_model_avg_regrets_mean = np.mean(generative_model_avg_regrets_runs, axis=0)
generative_model_std_regrets_std = np.sqrt(np.mean(np.square(generative_model_std_regrets_runs), axis=0))
episode_list=[10, 20, 40, 80, 160]
# Plot average regret with standard deviation for both models
plt.errorbar(episode_list, benchmark_avg_regrets_mean, yerr=benchmark_std_regrets_std, fmt='o',color='b')
plt.plot(episode_list, benchmark_avg_regrets_mean, linestyle='-', marker='o', color='b', label='(Qiu et al., 2021)') # Line connecting points
plt.errorbar(episode_list, max_variance_avg_regrets_mean, yerr=max_variance_std_regrets_std, fmt='o',color='r')
plt.plot(episode_list, max_variance_avg_regrets_mean, linestyle='-', marker='o', color='r', label='Greedy Max Variance') # Line connecting points
plt.errorbar(episode_list, max_variance2_avg_regrets_mean, yerr=max_variance2_std_regrets_std, fmt='o', color='g')
plt.plot(episode_list, max_variance2_avg_regrets_mean, linestyle='-', marker='o', color='g', label='Without generative model')
plt.errorbar(episode_list, generative_model_avg_regrets_mean, yerr=generative_model_std_regrets_std, fmt='o', color='purple')
plt.plot(episode_list, generative_model_avg_regrets_mean, linestyle='-', marker='o', color='purple', label='With generative model')
plt.xlabel(r'$N$',fontsize=20)
plt.ylabel(r'$V^{\star}(s) -V^{\pi}(s)$',fontsize=20)
# plt.title('Average Regret with Standard Deviation')
plt.legend()
plt.savefig(picture_path)
plt.close()