-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmajority_vote.py
More file actions
63 lines (51 loc) · 1.96 KB
/
Copy pathmajority_vote.py
File metadata and controls
63 lines (51 loc) · 1.96 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
import os
# TODO: not swisscheese in file name!!
RUN_SEQ_CONV1 = "python3 model.py --is_eval --emb_len=400" \
" --embedding_type=word2vec" \
" --ckpt_file=data/checkpoints/swisscheese_lstm_adam_ckpt-11400000-0.28.hdf5" \
" --seq_conv1 --train_file=data/full_train.txt"
RUN_SEQ_CONV2 = "python3 model.py --is_eval --emb_len=400" \
" --embedding_type=word2vec" \
" --ckpt_file=data/checkpoints/seq_conv_lstm_adam_ckpt-7600000-0.27.hdf5" \
" --seq_conv2 --train_file=data/full_train.txt"
RUN_BIDI = "python3 model.py --is_eval --emb_len=200" \
" --embedding_type=glove" \
" --ckpt_file=data/checkpoints/bidi_lstm_adam_ckpt-15600000-0.26.hdf5" \
" --bidi --train_file=data/full_train.txt"
RUN_GRU = "python3 model.py --is_eval --emb_len=200" \
" --embedding_type=glove" \
" --ckpt_file=data/checkpoints/gru_lstm_adam_ckpt-19200000-0.26.hdf5" \
" --gru --train_file=data/full_train.txt"
os.system(RUN_SEQ_CONV1)
os.system(RUN_SEQ_CONV2)
os.system(RUN_BIDI)
os.system(RUN_GRU)
SEQ_LEN = 40
ROOT_DIR = "data"
FILES = [
"seq_conv1_test_output.txt", "seq_conv2_test_output.txt",
"ensemble_test_outputs/conv_lstm_test_out_17400000.txt", # TODO: rename this
"bidi_test_output.txt", "gru_test_output.txt"]
result = []
for i in range(0, 10000):
result.append([0, 0])
for f in FILES:
file_path = os.path.join(ROOT_DIR, f)
file_pointer = open(file_path, 'r')
lines = file_pointer.readlines()[1:]
for i in range(0, len(lines)):
l = lines[i].strip().split(',')
if(int(l[1]) == 1):
result[i][1] += 1
else:
result[i][0] += 1
file_pointer.close()
max_sol = "max_sol.txt"
max_sol_path = os.path.join(ROOT_DIR, max_sol)
f = open(max_sol_path, 'w')
f.write("Id,Prediction\n")
for i in range(0, len(result)):
if (result[i][0] > result[i][1]):
f.write(str(i+1)+","+str("-1")+"\n")
else:
f.write(str(i+1)+","+str("1")+"\n")