-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformulaPerformance.py
More file actions
49 lines (42 loc) · 1.51 KB
/
formulaPerformance.py
File metadata and controls
49 lines (42 loc) · 1.51 KB
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
import numpy as np
import sys
def main():
if len(sys.argv) < 2:
print("Usage: python3 formulaPerformance.py filename")
exit()
f = open(sys.argv[1])
content = []
for line in f.readlines():
content += [list(map(int, line.split(",")))]
perfMatrix = np.array(content)
formulaPerf = [(0, 0, 0)]
score = 0
fromOptimum = 0
fromTop3 = 0
# print(perfMatrix)
for i in perfMatrix[1:]:
for index, j in enumerate(i):
# print(abs(index - (np.where(j == perfMatrix[0])[0][0])))
if j == perfMatrix[0][0]:
fromOptimum = abs(index - (np.where(j == perfMatrix[0])[0][0]))
fromTop3 += abs(index - (np.where(j == perfMatrix[0])[0][0]))
elif j == perfMatrix[0][1] or j == perfMatrix[0][2]:
fromTop3 += abs(index - (np.where(j == perfMatrix[0])[0][0]))
score += abs(index - (np.where(j == perfMatrix[0])[0][0]))
# print(index, np.where(j == perfMatrix[0])[0][0])
formulaPerf += [(score, fromOptimum, fromTop3)]
score = 0
fromOptimum = 0
fromTop3 = 0
print(perfMatrix)
print(formulaPerf)
names = ["Perceived real", "New formula", "Coupling", "Cohesion", "Cluster"]
print(
*[
f"{names[i]}: {j[0]}, optimum difference: {j[1]}, top 3 difference: {j[2]}"
for i, j in enumerate(formulaPerf)
],
sep="\n",
)
if __name__ == "__main__":
main()