-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathensemble1.py
More file actions
32 lines (26 loc) · 839 Bytes
/
ensemble1.py
File metadata and controls
32 lines (26 loc) · 839 Bytes
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
from typing import Counter
import pandas as pd
import numpy as np
import sys
import os
from collections import Counter
import sys
import shutil
import os
total_data = []
if os.path.exists("ensemble1") == False:
os.mkdir("ensemble1")
number = []
for file in sys.argv:
if file != "ensemble1.py":
number.append(file)
df = pd.DataFrame(pd.read_csv("experiment/"+file+"/submission1.csv"))
total_data.append(np.array(df["pred"]))
total_data = np.array(total_data).T
final_data = [Counter(x).most_common(1)[0][0] for x in total_data]
df = pd.DataFrame(columns=["pred"])
df["pred"] = final_data
if os.path.exists("ensemble1/"+("+".join(number))) == True:
shutil.rmtree("ensemble1/"+("+".join(number)))
os.mkdir("ensemble1/"+("+".join(number)))
df.to_csv("ensemble1/"+("+".join(number))+"/submission.csv")