-
Notifications
You must be signed in to change notification settings - Fork 57
/
draw.py
58 lines (53 loc) · 2.18 KB
/
draw.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
import matplotlib.pyplot as plt
import matplotlib as mpl
def openfile(filepath):
file = open(filepath)
y = []
while 1:
line = file.readline()
if line.rstrip('\n') == '':
break
y.append(float(line.rstrip('\n')))
if not line:
break
pass
file.close()
return y
if __name__ == '__main__':
mpl.use('TkAgg')
plt.figure()
epsilon_array = ['1.0', '5.0', '10.0', '20.0', '30.0']
plt.ylabel('Testing Accuracy')
plt.xlabel('Global Round')
for epsilon in epsilon_array:
y = openfile('./log/accfile_fed_mnist_cnn_100_iidFalse_dp_Gaussian_epsilon_{}.dat'.format(epsilon))
plt.plot(range(100), y, label=r'$\epsilon={}$'.format(epsilon))
y = openfile('./log/accfile_fed_mnist_cnn_100_iidFalse_dp_no_dp_epsilon_20.dat'.format(epsilon))
plt.plot(range(100), y, label=r'$\epsilon=+\infty$')
plt.title('Mnist Gaussian')
plt.legend()
plt.savefig('mnist_gaussian.png')
plt.figure()
epsilon_array = ['1.0', '5.0', '10.0', '20.0', '30.0']
plt.ylabel('Testing Accuracy')
plt.xlabel('Global Round')
for epsilon in epsilon_array:
y = openfile('./log/accfile_fed_mnist_cnn_100_iidFalse_dp_MA_epsilon_{}.dat'.format(epsilon))
plt.plot(range(100), y, label=r'$\epsilon={}$'.format(epsilon))
y = openfile('./log/accfile_fed_mnist_cnn_100_iidFalse_dp_no_dp_epsilon_20.dat'.format(epsilon))
plt.plot(range(100), y, label=r'$\epsilon=+\infty$')
plt.title('Mnist Gaussian Moment Account (q = 0.01)')
plt.legend()
plt.savefig('mnist_gaussian_MA.png')
plt.figure()
epsilon_array = ['10.0', '25.0', '50.0', '75.0', '100.0']
plt.ylabel('Testing Accuracy')
plt.xlabel('Global Round')
for epsilon in epsilon_array:
y = openfile('./log/accfile_fed_mnist_cnn_100_iidFalse_dp_Laplace_epsilon_{}.dat'.format(epsilon))
plt.plot(range(100), y, label=r'$\epsilon={}$'.format(epsilon))
y = openfile('./log/accfile_fed_mnist_cnn_100_iidFalse_dp_no_dp_epsilon_20.dat'.format(epsilon))
plt.plot(range(100), y, label=r'$\epsilon=+\infty$')
plt.title('Mnist Laplace')
plt.legend()
plt.savefig('mnist_gaussian_laplace.png')