-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathensemble.py
More file actions
24 lines (21 loc) · 882 Bytes
/
ensemble.py
File metadata and controls
24 lines (21 loc) · 882 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
import os
import sys
import pandas as pd
from configs.main_config import config
def ensemble(config):
experiment_path = os.path.join(config["experiment_folder"])
if not os.path.exists(experiment_path):
sys.exit("Path {} does not exist. Please run prepare_data.py and dissect.py before.".format(experiment_path))
i=0
for i in range(len(config["seeds"])):
df_curr = pd.read_table(os.path.join(config["experiment_folder"], "dissect_fractions_{}.txt".format(i)), index_col=0)
if i==0:
df_ens = df_curr
else:
df_ens = df_ens + df_curr
df_ens = df_ens/len(config["seeds"])
savepath = os.path.join(config["experiment_folder"], "dissect_fractions_ens.txt")
print("Ensemble predictions are saved to {}".format(savepath))
df_ens.to_csv(savepath, sep="\t")
if __name__=="__main__":
ensemble(config)