-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathretrieve_model.py
46 lines (37 loc) · 1.31 KB
/
retrieve_model.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
import shelve
import emukit
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
filename='/tmp/shelve.out'
my_shelf = shelve.open(filename)
for key in my_shelf:
print(key)
globals()[key]=my_shelf[key]
my_shelf.close()
# coord_results = bayesopt_loop.get_results().minimum_location
# print(coord_results)
# model_emukit.model.plot(levels = 5,visible_dims=[1,2])
# plt.title(r'$g_{\mathrm{ens}}$')
# ax = plt.gca()
# mappable = ax.collections[0]
# plt.colorbar(mappable)
# plt.savefig('model.png')
# plt.show()
# Select features to include in the plot
plot_feat = [r'$\mathrm{gap}_{\mathrm{cap}}$', r'$\mathrm{w}_{\mathrm{cap}}$', r'$\mathrm{l}_{\mathrm{cap}}$', r'$\mathrm{l}_{\mathrm{ind}}$', r'$\mathrm{w}_{\mathrm{ind}}$', r'$\mathrm{gap}_{\mathrm{ind}}$']
x = model_emukit.X
X = np.array(x)
X_frame = pd.DataFrame(X,columns = plot_feat)
y = model_emukit.Y
Y = np.array(y)
Y_frame = pd.DataFrame(Y,columns = ['g_ens'])
normalized_X=(X_frame-X_frame.min())/(X_frame.max()-X_frame.min())
# Concat classes with the normalized data
data_norm = pd.concat([normalized_X[plot_feat], Y_frame], axis=1)
data5 = data_norm.nsmallest(5, 'g_ens')
# Perform parallel coordinate plot
ax = pd.plotting.parallel_coordinates(data5,'g_ens')
# ax.get_legend().remove()
plt.title(r'Best 5 normalized parameter sets')
plt.show()