-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvisualize.py
More file actions
103 lines (83 loc) · 2.14 KB
/
visualize.py
File metadata and controls
103 lines (83 loc) · 2.14 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
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
import os
print(os.getcwd())
os.chdir(os.getcwd())
import numpy as np
import matplotlib.pyplot as plt
def visualizeFile(fileName):
f = open(fileName, "rt")
all = []
properties = []
uniqueProperties = []
for x in f:
current = x.replace('\n','').split("\t")
properties.append(current[0])
current[1] = int(current[1])
current[2] = int(current[2])
all.append(current)
#print(all)
uniqueProperties = sorted(list(set(properties)))
#print(properties)
correct = []
incorrect = []
for u in uniqueProperties:
cor = 0
incor = 0
for a in all:
if a[0] == u:
if a[1] == 1:
cor+=1
else:
incor+=1
correct.append(cor)
incorrect.append(incor)
#print(uniqueProperties)
print('Correct = ', correct)
print('Incorrect = ', incorrect)
N = len(uniqueProperties)
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars: can also be len(x) sequence
p1 = plt.barh(ind, correct, width)
p2 = plt.barh(ind, incorrect, width, left=correct)
plt.xlabel('Questions')
plt.title(fileName)
plt.yticks(ind, uniqueProperties)
plt.legend((p1[0], p2[0]), ('Correct', 'Incorrect'), ncol=2)
plt.tight_layout()
print('\nClose the image ' + fileName + ' to see the next one.')
plt.show()
try:
visualizeFile("singleEdge.txt")
except:
print('No data in singleEdge.txt')
try:
visualizeFile("chain.txt")
except:
print('No data in chain.txt')
try:
visualizeFile("chainSet.txt")
except:
print('No data in chainSet.txt')
try:
visualizeFile("tree.txt")
except:
print('No data in tree.txt')
try:
visualizeFile("star.txt")
except:
print('No data in star.txt')
try:
visualizeFile("cycle.txt")
except:
print('No data in cycle.txt')
try:
visualizeFile("forest.txt")
except:
print('No data in forest.txt')
try:
visualizeFile("flower.txt")
except:
print('No data in flower.txt')
try:
visualizeFile("flowerSet.txt")
except:
print('No data in flowerSet.txt')