-
Notifications
You must be signed in to change notification settings - Fork 5
/
11_03_averaging.py
executable file
·85 lines (59 loc) · 1.35 KB
/
11_03_averaging.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
import itertools
import numpy as np
import pickle
with open('11_03_results.txt') as f:
test = []
for line in f:
line = line.split() # to deal with blank
if line: # lines (ie skip them)
line = [int(i) for i in line]
test.append(line)
test = list(itertools.chain.from_iterable(test))
seq = 10
threshold = 5
newseq = []
start = test[0]
for ind,i in enumerate(test):
cnt = 0
for j in test[ind:]:
if (i+seq >=j):
cnt+=1
if cnt > threshold:
# print(i)
newseq.append(i)
start = newseq[0]
end = newseq[len(newseq)-1]
fin = []
for k in range(start,end+1):
fin.append(k)
# print(fin)
pred = [0]*329
gt = []
for i in fin:
pred[i] = 1
print(pred)
with open("/home/amit/Desktop/vignesh/allmerge.pickle",'rb') as f1:
spatial_test_data=pickle.load(f1)
key1 = spatial_test_data.keys()
keylist1=[]
for i in key1:
newkey1 = int(i)
keylist1.append(newkey1)
key2 = sorted(keylist1)
keylist2=[]
for i in key2:
if (i > 2000 and i < 4000): # change limits of indices for other cases
newkey2 = str(i)
keylist2.append(newkey2)
for k in keylist2:
gt.append(spatial_test_data[k])
print(gt)
accuracy0 = 0
cnt0 = 0
for i,j in zip(pred,gt):
if i==j:
accuracy0+=1
cnt0+=1
print(accuracy0)
print(cnt0)
print(accuracy0/float(cnt0))