-
Notifications
You must be signed in to change notification settings - Fork 0
/
ensemble.py
29 lines (20 loc) · 730 Bytes
/
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
import pandas as pd
import numpy as np
from glob import glob
import argparse
import os
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--sub-dir', type=str, default='./subs')
args, _ = parser.parse_known_args()
return args
if __name__ == '__main__':
args = parse_args()
subs = [pd.read_csv(csv) for csv in sorted(glob(os.path.join(args.sub_dir, '*csv')))]
sub_probs = [sub.target.rank(pct=True).values for sub in subs]
wts = [1/18]*18
assert len(wts)==len(sub_probs)
sub_ens = np.sum([wts[i]*sub_probs[i] for i in range(len(wts))],axis=0)
df_sub = subs[0]
df_sub['target'] = sub_ens
df_sub.to_csv(f"final_sub1.csv",index=False)