-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
109 lines (84 loc) · 4.49 KB
/
main.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
import scanner
import graph
import utility.genILoss as gil
import utility.aecsm as aecsm
import utility.discMetric as dm
if __name__ == '__main__':
dmarray = []
aecsmresults = []
numclasses = []
tablelength = []
kvalues = [1, 2, 5, 10, 25, 50, 75, 100]
kvalues2 = [2, 5, 25, 100]
discernibilityKValues = [2, 5, 10, 25, 50, 75, 100]
datasetsAdult = ["data/adult/income-values/adult.csv", "data/adult/income-values/2-anonymised.csv",
"data/adult/income-values/5-anonymised.csv", "data/adult/income-values/10-anonymised.csv",
"data/adult/income-values/25-anonymised.csv", "data/adult/income-values/50-anonymised.csv",
"data/adult/income-values/75-anonymised.csv", "data/adult/income-values/100-anonymised.csv"]
datasetsBikeSharing = ["data/bike-sharing/bike-sharing.csv", "data/bike-sharing/2-anonymised.csv",
"data/bike-sharing/5-anonymised.csv", "data/bike-sharing/10-anonymised.csv",
"data/bike-sharing/25-anonymised.csv", "data/bike-sharing/50-anonymised.csv",
"data/bike-sharing/75-anonymised.csv", "data/bike-sharing/100-anonymised.csv"]
datasetsBike = ["data/bike-sharing/2-anonymised.csv", "data/bike-sharing/5-anonymised.csv",
"data/bike-sharing/25-anonymised.csv", "data/bike-sharing/100-anonymised.csv"]
discernibilityBikeDataset = ["data/bike-sharing/2-anonymised.csv", "data/bike-sharing/5-anonymised.csv", "data/bike-sharing/10-anonymised.csv",
"data/bike-sharing/25-anonymised.csv", "data/bike-sharing/50-anonymised.csv", "data/bike-sharing/75-anonymised.csv",
"data/bike-sharing/100-anonymised.csv"]
# Generalized Information Loss Metric -> Adult Dataset
lossValues = []
for i in range(len(datasetsAdult)):
x, y = scanner.readData(datasetsAdult[i])
lossValues.append(gil.calcGenILoss(x, "data/arx/hierarchies/adult/"))
print("Generalized Information Loss Metric -> Adult Dataset")
for i in range(len(lossValues)):
print("k = " + str(kvalues[i]) + " GenILoss -> " + str("{0:.2f}".format(lossValues[i])))
print("")
# Generalized Information Loss Metric -> Bike Dataset
lossValues = []
for i in range(len(datasetsBikeSharing)):
x, y = scanner.readData(datasetsBikeSharing[i])
lossValues.append(gil.calcGenILoss(x, "data/arx/hierarchies/bike-sharing/"))
print("Generalized Information Loss Metric -> Bike Sharing Dataset")
for i in range(len(lossValues)):
print("k = " + str(kvalues[i]) + " GenILoss -> " + str("{0:.2f}".format(lossValues[i])))
print("")
# Average Equivalence Class Size Metric -> Adult Dataset
for i in range(len(kvalues)):
a, b, c = aecsm.calculateAECSM(kvalues[i], datasetsAdult[i])
tablelength.append(a)
numclasses.append(b)
aecsmresults.append(c)
print("Average Equivalence Class Size Metric -> Adult Dataset")
for i in range(len(kvalues)):
print("k = " + str(kvalues[i]) + " |EQs| = " + numclasses[i] + " |T| = " + tablelength[i] + " CAVG -> " +
aecsmresults[i])
aecsmresults = []
numclasses = []
tablelength = []
print("")
# Average Equivalence Class Size Metric -> Bike Sharing Dataset
for i in range(len(kvalues2)):
a, b, c = aecsm.calculateAECSM(kvalues2[i], datasetsBike[i])
tablelength.append(a)
numclasses.append(b)
aecsmresults.append(c)
print("Average Equivalence Class Size Metric -> Bike Sharing Dataset")
for i in range(len(kvalues2)):
print("k = " + str(kvalues2[i]) + " |EQs| = " + numclasses[i] + " |T| = " + tablelength[i] + " CAVG -> " +
aecsmresults[i])
print("")
# Discernibility Metric -> Adult Dataset
for i in range(len(kvalues)):
dmarray.append(dm.calcDiscernibilityMetric(kvalues[i], datasetsAdult[i]))
print("Discernibility Metric -> Adult Dataset")
for i in (range(len(kvalues))):
print("k = " + str(kvalues[i]) + " -> " + dmarray[i])
dmarray = []
print("")
# Discernibility Metric -> Bike Sharing Dataset
for i in range(len(discernibilityKValues)):
dmarray.append(dm.calcDiscernibilityMetric(discernibilityKValues[i], discernibilityBikeDataset[i]))
print("Discernibility Metric -> Bike Sharing Dataset")
for i in (range(len(discernibilityKValues))):
print("k = " + str(discernibilityKValues[i]) + " -> " + dmarray[i])
# PRIVACY MEASURES BELOW HERE