-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathensemble.py
executable file
·50 lines (40 loc) · 1.31 KB
/
ensemble.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
import os
import numpy as np
from config import *
import os.path as osp
input_dir = score_dir
inputs = [
'DENSE121_mixup0_foc1_weight0_decay0.01.csv',
'DENSE201_mixup0_foc1_weight0_decay0.01.csv',
'GAC_mixup0_foc1_weight0_decay0.01.csv',
'RES10_mixup0_foc0_weight1_decay0.01.csv',
'RES10_mixup0_foc1_weight0_decay0.01.csv',
'RES10_mixup0_foc1_weight0_decay0.01_crop.csv',
'RES10_mixup0_foc1_weight0_decay0.01_crop_1:7.csv',
'RES18_mixup0_foc1_weight0_decay0.01.csv',
'SE-RES10_mixup0_foc1_weight0_decay0.01.csv',
'SE-RES15_mixup0_foc1_weight0_decay0.01.csv',
'XCEPTION_mixup0_foc1_weight0_decay0.01.csv',
'score_0.9046128156960969.csv',
'score_0.9307034022124817.csv',
'score_0.9163013984554372.csv',
]
inputs = [os.path.join(input_dir, input) for input in inputs]
print(inputs)
# 84.5
# inputs = [
# 'pre_score_0.9765625.csv',
# 'pre_score_0.9861111111111112.csv',
# ]
out = 0
total_score = 0
for path in inputs:
# score = float(os.path.splitext(input)[0].split('_')[-1])
score = 1
preds = np.loadtxt(path, delimiter=',')
out += score * preds
total_score += score
out /= total_score
submit = np.eye(17)[np.argmax(out, axis=-1).reshape(-1)]
np.savetxt(osp.join(submit_dir, 'ensemble' + '.csv'), submit, delimiter=',', fmt='%d')
np.savetxt(osp.join(score_dir, 'ensemble' + '.csv'), out, delimiter=',', fmt='%.5f')