forked from aminrd/LineamentLearning
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LogParser.py
64 lines (50 loc) · 1.57 KB
/
LogParser.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
import re
import numpy as np
import scipy.io as sio
model_australia = {}
model_quest = {}
model_mixed = {}
models = [model_australia, model_quest, model_mixed]
for m in models:
m['Quest'] = {}
m['Australia'] = {}
for mp in ['Quest', 'Australia']:
m[mp]['Train_p'] = []
m[mp]['Train_n'] = []
m[mp]['Test_p'] = []
m[mp]['Test_n'] = []
m[mp]['All_p'] = []
m[mp]['All_n'] = []
with open("log.txt", "r") as f:
for it in range(72):
l1 = f.readline()[29:]
l2 = f.readline()[29:]
l3 = f.readline()[29:]
l4 = f.readline()[29:]
l5 = f.readline()[29:]
l6 = f.readline()[29:]
l7 = f.readline()[29:]
idx = int(re.findall("\d+", l2)[0])
idx = (idx - 9) // 4
if 'Quest' in l3:
model = model_quest
elif 'Mixed' in l3:
model = model_mixed
else:
model = model_australia
if 'QUEST' in l4:
map_name = 'Quest'
else:
map_name = 'Australia'
[p,n] = re.findall("\d+\.\d+", l5)
model[map_name]['Train_p'] += [float(p)]
model[map_name]['Train_n'] += [float(n)]
[p, n] = re.findall("\d+\.\d+", l6)
model[map_name]['Test_p'] += [float(p)]
model[map_name]['Test_n'] += [float(n)]
[p, n] = re.findall("\d+\.\d+", l7)
model[map_name]['All_p'] += [float(p)]
model[map_name]['All_n'] += [float(n)]
sio.savemat('Australia.mat', model_australia)
sio.savemat('Quest.mat', model_quest)
sio.savemat('Mixed.mat', model_mixed)