-
Notifications
You must be signed in to change notification settings - Fork 0
/
Figure8.py
329 lines (265 loc) · 15.3 KB
/
Figure8.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
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
import matplotlib.pyplot as plt
import numpy as np
import pickle
if __name__ == '__main__':
Figure = plt.figure(figsize=(15.36,8.96))
plt.subplot(2,3,1)
with open('Data/PreCOVID-Clearance/PreCOVID-Clearance-10.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
NoMean = []
RandMean = []
RandStd = []
DegMean = []
DegStd = []
ShorrMean = []
ShorrStd = []
GreedyMean = []
GreedyStd = []
for k in range(500,5000,500):
NoMean.append(np.mean(np.sum(loads_other_no[int((k-500)/500),:,:],axis=1)))
RandMean.append(np.mean(np.sum(loads_other_rand[int((k-500)/500),:,:],axis=1)))
RandStd.append(np.std(np.sum(loads_other_rand[int((k-500)/500),:,:],axis=1)))
DegMean.append(np.mean(np.sum(loads_other_deg[int((k-500)/500),:,:],axis=1)))
DegStd.append(np.std(np.sum(loads_other_deg[int((k-500)/500),:,:],axis=1)))
ShorrMean.append(np.mean(np.sum(loads_other_shorr[int((k-500)/500),:,:],axis=1)))
ShorrStd.append(np.std(np.sum(loads_other_shorr[int((k-500)/500),:,:],axis=1)))
GreedyMean.append(np.mean(np.sum(loads_other_greedy[int((k-500)/500),:,:],axis=1)))
GreedyStd.append(np.std(np.sum(loads_other_greedy[int((k-500)/500),:,:],axis=1)))
RandMean = np.array(RandMean)/np.array(NoMean)
RandStd = np.array(RandStd)/np.array(NoMean)
DegMean = np.array(DegMean)/np.array(NoMean)
DegStd = np.array(DegStd)/np.array(NoMean)
ShorrMean = np.array(ShorrMean)/np.array(NoMean)
ShorrStd = np.array(ShorrStd)/np.array(NoMean)
GreedyMean = np.array(GreedyMean)/np.array(NoMean)
GreedyStd = np.array(GreedyStd)/np.array(NoMean)
x1 = np.array(list(range(9))) + 1 - 0.3
x2 = np.array(list(range(9))) + 1 - 0.1
x3 = np.array(list(range(9))) + 1 + 0.1
x4 = np.array(list(range(9))) + 1 + 0.3
plt.bar(x1,RandMean,yerr=RandStd,capsize=4,color='C7',label='Random',width=0.2)
plt.bar(x2,DegMean,yerr=DegStd,capsize=4,color='C0',label='Degree',width=0.2)
plt.bar(x3,ShorrMean,yerr=ShorrStd,capsize=4,color='#6B8E23',label='Shorr',width=0.2)
plt.bar(x4,GreedyMean,yerr=GreedyStd,capsize=4, color='C3',label='Greedy-Spectral',width=0.2)
plt.xlabel(r"Budget $k$", fontsize=18)
plt.ylabel(r"$\gamma_{Loads}$", fontsize=18)
plt.hlines(1,0.5,10.5,linewidth=1,color='black',linestyle='dashed')
plt.xticks([0,1,2,3,4,5,6,7,8,9],[0,500,1000,1500,2000,2500,3000,3500,4000,4500],fontsize=10)
plt.yticks([0,0.2,0.4,0.6,0.8,1.0],[0,0.2,0.4,0.6,0.8,1.0],fontsize=12)
plt.xlim(0.5,9.5)
plt.ylim(bottom=0,top=1.1)
plt.title('UVA-PreCOVID',fontsize=14)
plt.legend(loc=2,fontsize=14)
plt.subplot(2,3,2)
with open('Data/PreCOVID-Clearance/PreCOVID-Clearance-10.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
NoMean = []
RandMean = []
RandStd = []
DegMean = []
DegStd = []
ShorrMean = []
ShorrStd = []
GreedyMean = []
GreedyStd = []
for k in range(500,5000,500):
NoMean.append(np.mean(cum_new_cases_no[int((k-500)/500),:,-1]))
RandMean.append(np.mean(cum_new_cases_rand[int((k-500)/500),:,-1]))
RandStd.append(np.std(cum_new_cases_rand[int((k-500)/500),:,-1]))
DegMean.append(np.mean(cum_new_cases_deg[int((k-500)/500),:,-1]))
DegStd.append(np.std(cum_new_cases_deg[int((k-500)/500),:,-1]))
ShorrMean.append(np.mean(cum_new_cases_shorr[int((k-500)/500),:,-1]))
ShorrStd.append(np.std(cum_new_cases_shorr[int((k-500)/500),:,-1]))
GreedyMean.append(np.mean(cum_new_cases_greedy[int((k-500)/500),:,-1]))
GreedyStd.append(np.std(cum_new_cases_greedy[int((k-500)/500),:,-1]))
RandMean = np.array(RandMean)/np.array(NoMean)
RandStd = np.array(RandStd)/np.array(NoMean)
DegMean = np.array(DegMean)/np.array(NoMean)
DegStd = np.array(DegStd)/np.array(NoMean)
ShorrMean = np.array(ShorrMean)/np.array(NoMean)
ShorrStd = np.array(ShorrStd)/np.array(NoMean)
GreedyMean = np.array(GreedyMean)/np.array(NoMean)
GreedyStd = np.array(GreedyStd)/np.array(NoMean)
x1 = np.array(list(range(9))) + 1 - 0.3
x2 = np.array(list(range(9))) + 1 - 0.1
x3 = np.array(list(range(9))) + 1 + 0.1
x4 = np.array(list(range(9))) + 1 + 0.3
plt.bar(x1,RandMean,yerr=RandStd,capsize=4,color='C7',label='Random',width=0.2)
plt.bar(x2,DegMean,yerr=DegStd,capsize=4,color='C0',label='Degree',width=0.2)
plt.bar(x3,ShorrMean,yerr=ShorrStd,capsize=4,color='#6B8E23',label='Shorr',width=0.2)
plt.bar(x4,GreedyMean,yerr=GreedyStd,capsize=4, color='C3',label='Greedy-Spectral',width=0.2)
plt.xlabel(r"Budget $k$", fontsize=18)
plt.ylabel(r"$\gamma_{Cases}$", fontsize=18)
plt.hlines(1,0.5,10.5,linewidth=1,color='black',linestyle='dashed')
plt.xticks([0,1,2,3,4,5,6,7,8,9],[0,500,1000,1500,2000,2500,3000,3500,4000,4500],fontsize=10)
plt.yticks([0,0.2,0.4,0.6,0.8,1.0],[0,0.2,0.4,0.6,0.8,1.0],fontsize=12)
plt.xlim(0.5,9.5)
plt.ylim(bottom=0,top=1.1)
plt.title('UVA-PreCOVID',fontsize=14)
#plt.legend(loc=1,fontsize=14)
plt.subplot(2,3,3)
with open('Data/PreCOVID-Clearance/PreCOVID-Clearance-10.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
Start = 200
End = 1200
ThresholdList = range(Start,End+1,1)
XValue = []
XLabel = []
for X in range(Start,End+1,100):
XValue.append((X-Start))
XLabel.append(str(X))
for k in [4000]:
Rand = []
Deg = []
Shorr = []
Greedy = []
with open('Data/PreCOVID-Clearance/PreCOVID-Clearance-10.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
for threshold in ThresholdList:
Rand.append(len(np.where(cum_new_cases_rand[int((k-500)/500),:,-1]>threshold)[0]))
Deg.append(len(np.where(cum_new_cases_deg[int((k-500)/500),:,-1]>threshold)[0]))
Shorr.append(len(np.where(cum_new_cases_shorr[int((k-500)/500),:,-1]>threshold)[0]))
Greedy.append(len(np.where(cum_new_cases_greedy[int((k-500)/500),:,-1]>threshold)[0]))
X = np.array(list(range(len(ThresholdList)))) + 1
plt.plot(X, Rand, '-', label='Random', linewidth=2, color='C7')
plt.plot(X, Deg, '-', label='Degree', linewidth=2, color='C0')
plt.plot(X, Shorr, '-', label='Shorr Score', linewidth=2, color='#6B8E23')
plt.plot(X, Greedy, '-', label='Greedy-Spectral', linewidth=2, color='C3')
plt.xlabel("Target", fontsize=18)
plt.ylabel(r"$Prob[Cases > Target]$", fontsize=18)
plt.xticks(XValue,XLabel,fontsize=10)
plt.xlim(0,1000)
plt.yticks([0,200,400,600,800,1000],['0','0.2','0.4','0.6','0.8','1.0'],fontsize=12)
plt.ylim(bottom=0,top=1000)
plt.title('UVA-PreCOVID: Budget k='+str(k),fontsize=14)
plt.subplot(2,3,4)
with open('Data/PostCOVID-Clearance/PostCOVID-Clearance-10.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
NoMean = []
RandMean = []
RandStd = []
DegMean = []
DegStd = []
ShorrMean = []
ShorrStd = []
GreedyMean = []
GreedyStd = []
for k in range(500,5000,500):
NoMean.append(np.mean(np.sum(loads_other_no[int((k-500)/500),:,:],axis=1)))
RandMean.append(np.mean(np.sum(loads_other_rand[int((k-500)/500),:,:],axis=1)))
RandStd.append(np.std(np.sum(loads_other_rand[int((k-500)/500),:,:],axis=1)))
DegMean.append(np.mean(np.sum(loads_other_deg[int((k-500)/500),:,:],axis=1)))
DegStd.append(np.std(np.sum(loads_other_deg[int((k-500)/500),:,:],axis=1)))
ShorrMean.append(np.mean(np.sum(loads_other_shorr[int((k-500)/500),:,:],axis=1)))
ShorrStd.append(np.std(np.sum(loads_other_shorr[int((k-500)/500),:,:],axis=1)))
GreedyMean.append(np.mean(np.sum(loads_other_greedy[int((k-500)/500),:,:],axis=1)))
GreedyStd.append(np.std(np.sum(loads_other_greedy[int((k-500)/500),:,:],axis=1)))
RandMean = np.array(RandMean)/np.array(NoMean)
RandStd = np.array(RandStd)/np.array(NoMean)
DegMean = np.array(DegMean)/np.array(NoMean)
DegStd = np.array(DegStd)/np.array(NoMean)
ShorrMean = np.array(ShorrMean)/np.array(NoMean)
ShorrStd = np.array(ShorrStd)/np.array(NoMean)
GreedyMean = np.array(GreedyMean)/np.array(NoMean)
GreedyStd = np.array(GreedyStd)/np.array(NoMean)
x1 = np.array(list(range(9))) + 1 - 0.3
x2 = np.array(list(range(9))) + 1 - 0.1
x3 = np.array(list(range(9))) + 1 + 0.1
x4 = np.array(list(range(9))) + 1 + 0.3
plt.bar(x1,RandMean,yerr=RandStd,capsize=4,color='C7',label='Random',width=0.2)
plt.bar(x2,DegMean,yerr=DegStd,capsize=4,color='C0',label='Degree',width=0.2)
plt.bar(x3,ShorrMean,yerr=ShorrStd,capsize=4,color='#6B8E23',label='Shorr',width=0.2)
plt.bar(x4,GreedyMean,yerr=GreedyStd,capsize=4, color='C3',label='Greedy-Spectral',width=0.2)
plt.xlabel(r"Budget $k$"+"\n\n(a) "+r"$\gamma_{Loads}$", fontsize=18)
plt.ylabel(r"$\gamma_{Loads}$", fontsize=18)
plt.hlines(1,0.5,10.5,linewidth=1,color='black',linestyle='dashed')
plt.xticks([0,1,2,3,4,5,6,7,8,9],[0,500,1000,1500,2000,2500,3000,3500,4000,4500],fontsize=10)
plt.yticks([0,0.2,0.4,0.6,0.8,1.0],[0,0.2,0.4,0.6,0.8,1.0],fontsize=12)
plt.xlim(0.5,9.5)
plt.ylim(bottom=0,top=1.1)
plt.title('UVA-PostCOVID',fontsize=14)
plt.legend(loc=2,fontsize=14)
plt.subplot(2,3,5)
with open('Data/PostCOVID-Clearance/PostCOVID-Clearance-10.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
NoMean = []
RandMean = []
RandStd = []
DegMean = []
DegStd = []
ShorrMean = []
ShorrStd = []
GreedyMean = []
GreedyStd = []
for k in range(500,5000,500):
NoMean.append(np.mean(cum_new_cases_no[int((k-500)/500),:,-1]))
RandMean.append(np.mean(cum_new_cases_rand[int((k-500)/500),:,-1]))
RandStd.append(np.std(cum_new_cases_rand[int((k-500)/500),:,-1]))
DegMean.append(np.mean(cum_new_cases_deg[int((k-500)/500),:,-1]))
DegStd.append(np.std(cum_new_cases_deg[int((k-500)/500),:,-1]))
ShorrMean.append(np.mean(cum_new_cases_shorr[int((k-500)/500),:,-1]))
ShorrStd.append(np.std(cum_new_cases_shorr[int((k-500)/500),:,-1]))
GreedyMean.append(np.mean(cum_new_cases_greedy[int((k-500)/500),:,-1]))
GreedyStd.append(np.std(cum_new_cases_greedy[int((k-500)/500),:,-1]))
RandMean = np.array(RandMean)/np.array(NoMean)
RandStd = np.array(RandStd)/np.array(NoMean)
DegMean = np.array(DegMean)/np.array(NoMean)
DegStd = np.array(DegStd)/np.array(NoMean)
ShorrMean = np.array(ShorrMean)/np.array(NoMean)
ShorrStd = np.array(ShorrStd)/np.array(NoMean)
GreedyMean = np.array(GreedyMean)/np.array(NoMean)
GreedyStd = np.array(GreedyStd)/np.array(NoMean)
x1 = np.array(list(range(9))) + 1 - 0.3
x2 = np.array(list(range(9))) + 1 - 0.1
x3 = np.array(list(range(9))) + 1 + 0.1
x4 = np.array(list(range(9))) + 1 + 0.3
plt.bar(x1,RandMean,yerr=RandStd,capsize=4,color='C7',label='Random',width=0.2)
plt.bar(x2,DegMean,yerr=DegStd,capsize=4,color='C0',label='Degree',width=0.2)
plt.bar(x3,ShorrMean,yerr=ShorrStd,capsize=4,color='#6B8E23',label='Shorr',width=0.2)
plt.bar(x4,GreedyMean,yerr=GreedyStd,capsize=4, color='C3',label='Greedy-Spectral',width=0.2)
plt.xlabel(r"Budget $k$"+"\n\n(b) "+r"$\gamma_{Cases}$", fontsize=18)
plt.ylabel(r"$\gamma_{Cases}$", fontsize=18)
plt.hlines(1,0.5,10.5,linewidth=1,color='black',linestyle='dashed')
plt.xticks([0,1,2,3,4,5,6,7,8,9],[0,500,1000,1500,2000,2500,3000,3500,4000,4500],fontsize=10)
plt.yticks([0,0.2,0.4,0.6,0.8,1.0],[0,0.2,0.4,0.6,0.8,1.0],fontsize=12)
plt.xlim(0.5,9.5)
plt.ylim(bottom=0,top=1.1)
plt.title('UVA-PostCOVID',fontsize=14)
#plt.legend(loc=1,fontsize=14)
plt.subplot(2,3,6)
with open('Data/PostCOVID-Clearance/PostCOVID-Clearance-10.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
Start = 200
End = 1200
ThresholdList = range(Start,End+1,1)
XValue = []
XLabel = []
for X in range(Start,End+1,100):
XValue.append((X-Start))
XLabel.append(str(X))
for k in [4000]:
Rand = []
Deg = []
Shorr = []
Greedy = []
with open('Data/PostCOVID-Clearance/PostCOVID-Clearance-10.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
for threshold in ThresholdList:
Rand.append(len(np.where(cum_new_cases_rand[int((k-500)/500),:,-1]>threshold)[0]))
Deg.append(len(np.where(cum_new_cases_deg[int((k-500)/500),:,-1]>threshold)[0]))
Shorr.append(len(np.where(cum_new_cases_shorr[int((k-500)/500),:,-1]>threshold)[0]))
Greedy.append(len(np.where(cum_new_cases_greedy[int((k-500)/500),:,-1]>threshold)[0]))
X = np.array(list(range(len(ThresholdList)))) + 1
plt.plot(X, Rand, '-', label='Random', linewidth=2, color='C7')
plt.plot(X, Deg, '-', label='Degree', linewidth=2, color='C0')
plt.plot(X, Shorr, '-', label='Shorr Score', linewidth=2, color='#6B8E23')
plt.plot(X, Greedy, '-', label='Greedy-Spectral', linewidth=2, color='C3')
plt.xlabel("Target\n\n(c) "+r"$Prob[Cases > Target]$", fontsize=18)
plt.ylabel(r"$Prob[Cases > Target]$", fontsize=18)
plt.xticks(XValue,XLabel,fontsize=10)
plt.xlim(0,1000)
plt.yticks([0,200,400,600,800,1000],['0','0.2','0.4','0.6','0.8','1.0'],fontsize=12)
plt.ylim(bottom=0,top=1000)
plt.title('UVA-PostCOVID: Budget k='+str(k),fontsize=14)
plt.tight_layout()
plt.savefig('Figure8.pdf')