-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaverage.py
33 lines (30 loc) · 1.12 KB
/
average.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
import os
text_path = [os.path.join(root,name) for root, dirs, files in os.walk(os.getcwd()) for name in files if "log.pooling.clustering.balanced" in name and name.endswith('.txt')]
print "==============================START======================"
for name in text_path:
ari = []
hs = []
with open(name, 'r') as fp:
for line in fp:
line=line.strip()
if line.startswith("Adjusted Rand Index"):
ari.append(float(line.split()[-1]))
elif line.startswith("Homogeneity Score"):
hs.append(float(line.split()[-1]))
print name
print "ARI = %.4f" %(1.0*sum(ari)/len(ari))
print "MS = %.4f" %(1.0*sum(hs)/len(hs))
print "====================================================="
'''
ari = []
hs = []
with open("log.clustering.balanced.txt", 'r') as fp:
for line in fp:
line=line.strip()
if line.startswith("Adjusted Rand Index"):
ari.append(float(line.split()[-1]))
elif line.startswith("Homogeneity Score"):
hs.append(float(line.split()[-1]))
print 1.0*sum(ari)/len(ari)
print 1.0*sum(hs)/len(hs)
'''