Commit a02a8c25 authored by Nicole Bussola's avatar Nicole Bussola
Browse files

manage different models

parent 41142126
......@@ -3,12 +3,13 @@ import os
import subprocess
#%%
# these can be set on runtime:
# snakemake --config datafolder="mydata" outfolder="out" dataset="breast" target="ER" layer1="gene" layer2="cnv" layer3="prot" split_id="1"(...)
# snakemake --config datafolder="mydata" outfolder="out" dataset="breast" model="RandomForest" target="ER" layer1="gene" layer2="cnv" layer3="prot" split_id="1"(...)
DATAFOLDER = config['datafolder']
OUTFOLDER = config['outfolder']
DATASET = config['dataset']
MODEL = config['model']
TARGET = config['target']
SPLIT_ID = config['split_id']
......@@ -19,34 +20,34 @@ LAYERS_CONCAT = "_".join(LAYERS)
rule all:
input:
expand("{outfolder}/{dataset}/{target}/{split_id}/juxt/{layers}_tr_MCC_scores.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNF/{layers}_tr_MCC_scores.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNFi/{layers}_tr_MCC_scores.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{split_id}/single/{layer}_tr_MCC_scores.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layer=LAYERS, split_id=SPLIT_ID)
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/juxt/{layers}_tr_MCC_scores.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNF/{layers}_tr_MCC_scores.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNFi/{layers}_tr_MCC_scores.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/single/{layer}_tr_MCC_scores.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layer=LAYERS, split_id=SPLIT_ID)
rule ml_juxt_tr:
input:
os.path.join(DATAFOLDER, "{dataset}/{target}/{split_id}/{layers}_tr.txt"),
os.path.join(DATAFOLDER, "{dataset}/{target}/{split_id}/labels_{target}_tr.txt")
output:
"{outfolder}/{dataset}/{target}/{split_id}/juxt/{layers}_tr_RandomForest_KBest.log"
"{outfolder}/{dataset}/{target}/{model}/{split_id}/juxt/{layers}_tr_{model}_KBest.log"
shell:
"python sklearn_rf_training_fixrank.py {input} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.split_id}/juxt --ranking KBest"
"python sklearn_training.py {input} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.model}/{wildcards.split_id}/juxt --ranking KBest"
rule ml_juxt_val:
input:
"{outfolder}/{dataset}/{target}/{split_id}/juxt/{layers}_tr_RandomForest_KBest.log",
"{outfolder}/{dataset}/{target}/{model}/{split_id}/juxt/{layers}_tr_{model}_KBest.log",
os.path.join(DATAFOLDER, "{dataset}/{target}/{split_id}/{layers}_ts.txt"),
os.path.join(DATAFOLDER, "{dataset}/{target}/{split_id}/labels_{target}_ts.txt")
output:
"{outfolder}/{dataset}/{target}/{split_id}/juxt/{layers}_tr_MCC_scores.txt"
"{outfolder}/{dataset}/{target}/{model}/{split_id}/juxt/{layers}_tr_MCC_scores.txt"
shell:
"python sklearn_rf_validation_writeperf.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.split_id}/juxt --tslab {input[2]}"
"python sklearn_validation.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/wildcards.model}/{wildcards.split_id}/juxt --tslab {input[2]}"
rule snf:
......@@ -57,8 +58,8 @@ rule snf:
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, split_id=SPLIT_ID)
threads: 8
output:
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNF/INF_{layers}_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNF/INF_{layers}_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
run:
all_input = [i[1] for i in input.allitems()]
inputfiles = " ".join(all_input[:-1])
......@@ -74,36 +75,36 @@ rule ml_rsnf_tr:
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{datafolder}/{dataset}/{target}/{split_id}/labels_{target}_tr.txt",
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, split_id=SPLIT_ID),
"{outfolder}/{dataset}/{target}/{split_id}/rSNF/INF_{layers}_tr.txt",
"{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNF/INF_{layers}_tr.txt",
output:
"{outfolder}/{dataset}/{target}/{split_id}/rSNF/{layers}_tr_RandomForest_rankList.log",
"{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNF/{layers}_tr_{model}_rankList.log",
shell:
"python sklearn_rf_training_fixrank.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.split_id}/rSNF --ranking rankList --rankFeats {input[2]}"
"python sklearn_training.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.model}/{wildcards.split_id}/rSNF --ranking rankList --rankFeats {input[2]}"
rule ml_rsnf_val:
input:
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNF/{layers}_tr_RandomForest_rankList.log",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNF/{layers}_tr_{model}_rankList.log",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{datafolder}/{dataset}/{target}/{split_id}/{layers}_ts.txt",
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{datafolder}/{dataset}/{target}/{split_id}/labels_{target}_ts.txt",
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
output:
"{outfolder}/{dataset}/{target}/{split_id}/rSNF/{layers}_tr_MCC_scores.txt",
"{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNF/{layers}_tr_MCC_scores.txt",
shell:
"python sklearn_rf_validation_writeperf.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.split_id}/rSNF --tslab {input[2]}"
"python sklearn_validation.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.model}/{wildcards.split_id}/rSNF --tslab {input[2]}"
rule myintersect:
input:
expand("{outfolder}/{dataset}/{target}/{split_id}/juxt/{layers}_tr_RandomForest_KBest.log",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNF/{layers}_tr_RandomForest_rankList.log",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/juxt/{layers}_tr_{model}_KBest.log",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNF/{layers}_tr_{model}_rankList.log",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
output:
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNFi/{layers}_intersect_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNFi/{layers}_intersect_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
shell:
"python intersect_biomarkers.py {input} {output}" ########
......@@ -112,39 +113,39 @@ rule extract:
input:
expand("{datafolder}/{dataset}/{target}/{split_id}/{layers}_tr.txt",
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID),
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNFi/{layers}_intersect_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNFi/{layers}_intersect_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
output:
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNFi/{layers}_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNFi/{layers}_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, layers=LAYERS_CONCAT, split_id=SPLIT_ID)
shell:
"python extract_topfeats_onecol.py {input} {output}"
rule ml_rsnfi_tr:
input:
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNFi/{layers}_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, split_id=SPLIT_ID, layers=LAYERS_CONCAT),
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNFi/{layers}_tr.txt",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, split_id=SPLIT_ID, layers=LAYERS_CONCAT),
expand("{datafolder}/{dataset}/{target}/{split_id}/labels_{target}_tr.txt",
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, split_id=SPLIT_ID, layers=LAYERS_CONCAT),
output:
"{outfolder}/{dataset}/{target}/{split_id}/rSNFi/{layers}_tr_RandomForest_KBest.log"
"{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNFi/{layers}_tr_{model}_KBest.log"
shell:
"python sklearn_rf_training_fixrank.py {input} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.split_id}/rSNFi --ranking KBest"
"python sklearn_rf_training_fixrank.py {input} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.model}/{wildcards.split_id}/rSNFi --ranking KBest"
rule ml_rsnfi_val:
input:
expand("{outfolder}/{dataset}/{target}/{split_id}/rSNFi/{layers}_tr_RandomForest_KBest.log",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, split_id=SPLIT_ID, layers=LAYERS_CONCAT),
expand("{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNFi/{layers}_tr_{model}_KBest.log",
outfolder=OUTFOLDER, dataset=DATASET, target=TARGET, model=MODEL, split_id=SPLIT_ID, layers=LAYERS_CONCAT),
expand("{datafolder}/{dataset}/{target}/{split_id}/{layers}_ts.txt",
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, split_id=SPLIT_ID, layers=LAYERS_CONCAT),
expand("{datafolder}/{dataset}/{target}/{split_id}/labels_{target}_ts.txt",
datafolder=DATAFOLDER, dataset=DATASET, target=TARGET, split_id=SPLIT_ID, layers=LAYERS_CONCAT)
output:
"{outfolder}/{dataset}/{target}/{split_id}/rSNFi/{layers}_tr_MCC_scores.txt"
"{outfolder}/{dataset}/{target}/{model}/{split_id}/rSNFi/{layers}_tr_MCC_scores.txt"
shell:
"python sklearn_rf_validation_writeperf.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.split_id}/rSNFi --tslab {input[2]}"
"python sklearn_validation.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.model}/{wildcards.split_id}/rSNFi --tslab {input[2]}"
rule single_tr:
......@@ -152,16 +153,16 @@ rule single_tr:
os.path.join(DATAFOLDER, "{dataset}/{target}/{split_id}/{layer}_tr.txt"),
os.path.join(DATAFOLDER, "{dataset}/{target}/{split_id}/labels_{target}_tr.txt")
output:
"{outfolder}/{dataset}/{target}/{split_id}/single/{layer}_tr_RandomForest_KBest.log"
"{outfolder}/{dataset}/{target}/{model}/{split_id}/single/{layer}_tr_{model}_KBest.log"
shell:
"python sklearn_rf_training_fixrank.py {input} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.split_id}/single --ranking KBest"
"python sklearn_training.py {input} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.model}/{wildcards.split_id}/single --ranking KBest"
rule single_val:
input:
"{outfolder}/{dataset}/{target}/{split_id}/single/{layer}_tr_RandomForest_KBest.log",
"{outfolder}/{dataset}/{target}/{model}/{split_id}/single/{layer}_tr_{model}_KBest.log",
os.path.join(DATAFOLDER, "{dataset}/{target}/{split_id}/{layer}_ts.txt"),
os.path.join(DATAFOLDER, "{dataset}/{target}/{split_id}/labels_{target}_ts.txt")
output:
"{outfolder}/{dataset}/{target}/{split_id}/single/{layer}_tr_MCC_scores.txt"
"{outfolder}/{dataset}/{target}/{model}/{split_id}/single/{layer}_tr_MCC_scores.txt"
shell:
"python sklearn_rf_validation_writeperf.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.split_id}/single --tslab {input[2]}"
"python sklearn_validation_.py {input[0]} {input[1]} {wildcards.outfolder}/{wildcards.dataset}/{wildcards.target}/{wildcards.model}/{wildcards.split_id}/single --tslab {input[2]}"
......@@ -28,6 +28,7 @@ parser.add_argument('--datafolder', type=str, help='Main data folder')
parser.add_argument('--outfolder', type=str, help='Results folder')
parser.add_argument('--dataset', type=str, help='Dataset name')
parser.add_argument('--target', type=str, help='Clinical endpoint')
parser.add_argument('--model', type=str, help='Classifiers implemented, randomForest or LSVM')
parser.add_argument('--layers', type=str, nargs='+', help='')
parser.add_argument('--n_splits', type=int, help='')
parser.add_argument('--mode', type=str, help='rSNF, rSNFi, single')
......@@ -39,6 +40,7 @@ DATAFOLDER = args.datafolder
DATASET = args.dataset
OUTFOLDER = args.outfolder
TARGET = args.target
MODEL = args.model
LAYERS = args.layers
N_SPLITS = args.n_splits
MODE = args.mode
......@@ -58,9 +60,9 @@ for k in range(2, N_LAYERS + 1):
for i in range(N_SPLITS):
if MODE == 'rSNF':
file_ranking = os.path.join(OUTFOLDER, DATASET, TARGET, f'{i}/{MODE}/{layers_concat}_tr_RandomForest_rankList_ranking.csv.gz')
file_ranking = os.path.join(OUTFOLDER, DATASET, TARGET, MODEL, f'{i}/{MODE}/{layers_concat}_tr_RandomForest_rankList_ranking.csv.gz')
else:
file_ranking = os.path.join(OUTFOLDER, DATASET, TARGET,f'{i}/{MODE}/{layers_concat}_tr_RandomForest_KBest_ranking.csv.gz')
file_ranking = os.path.join(OUTFOLDER, DATASET, TARGET, MODEL, f'{i}/{MODE}/{layers_concat}_tr_RandomForest_KBest_ranking.csv.gz')
rank = pd.read_csv(file_ranking, header=None, sep='\t').values
rankings.append(rank)
......@@ -72,4 +74,4 @@ for k in range(2, N_LAYERS + 1):
for i, pos in zip(BORDA_ID, BORDA_POS):
borda_df = borda_df.append({'FEATURE_ID': i, 'FEATURE_NAME': var_names[i], 'MEAN_POS': pos+1}, ignore_index=True)
borda_df.to_csv(f"{OUTFOLDER}/{DATASET}/{TARGET}/Borda_allSpilts_{MODE}_{layers_concat}.txt", sep='\t', index=False, float_format="%.3f")
borda_df.to_csv(f"{OUTFOLDER}/{DATASET}/{TARGET}/{MODEL}/Borda_allSplits_{MODE}_{layers_concat}.txt", sep='\t', index=False, float_format="%.3f")
......@@ -27,6 +27,7 @@ parser.add_argument('--datafolder', type=str, help='Main data folder')
parser.add_argument('--outfolder', type=str, help='Results folder')
parser.add_argument('--dataset', type=str, help='Dataset name')
parser.add_argument('--target', type=str, help='Clinical endpoint')
parser.add_argument('--model', type=str, help='Classifiers implemented, randomForest or LSVM')
parser.add_argument('--layers', type=str, nargs='+', help='')
parser.add_argument('--n_splits', type=int, help='')
parser.add_argument('--mode', type=str, help='rSNFi custom Borda')
......@@ -38,6 +39,7 @@ DATAFOLDER = args.datafolder
DATASET = args.dataset
OUTFOLDER = args.outfolder
TARGET = args.target
MODEL = args.model
LAYERS = args.layers
N_SPLITS = args.n_splits
MODE = args.mode
......@@ -58,7 +60,7 @@ for k in range(2, N_LAYERS + 1):
all_feats=[]
for i in range(N_SPLITS):
file_featureList = os.path.join(OUTFOLDER, DATASET, TARGET,f'{i}/{MODE}/{layers_concat}_tr_RandomForest_KBest_featurelist.txt')
file_featureList = os.path.join(OUTFOLDER, DATASET, TARGET, MODEL, f'{i}/{MODE}/{layers_concat}_tr_RandomForest_KBest_featurelist.txt')
feats = pd.read_csv(file_featureList, sep='\t')
all_feats.extend(list(feats.FEATURE_NAME))
......@@ -74,7 +76,7 @@ for k in range(2, N_LAYERS + 1):
for i in range(N_SPLITS):
file_featureList = os.path.join(OUTFOLDER, DATASET, TARGET,f'{i}/{MODE}/{layers_concat}_tr_RandomForest_KBest_featurelist.txt')
file_featureList = os.path.join(OUTFOLDER, DATASET, TARGET, MODEL, f'{i}/{MODE}/{layers_concat}_tr_RandomForest_KBest_featurelist.txt')
feats = pd.read_csv(file_featureList, sep='\t')
z=[None]*len(feats)
......@@ -82,7 +84,7 @@ for k in range(2, N_LAYERS + 1):
for k in range(len(feats)):
z[feats.FEATURE_ID[k]]=feats.FEATURE_NAME[k]
file_ranking = os.path.join(OUTFOLDER, DATASET, TARGET,f'{i}/{MODE}/{layers_concat}_tr_RandomForest_KBest_ranking.csv.gz')
file_ranking = os.path.join(OUTFOLDER, DATASET, TARGET, MODEL, f'{i}/{MODE}/{layers_concat}_tr_RandomForest_KBest_ranking.csv.gz')
rankings = pd.read_csv(file_ranking, header=None, sep='\t')
for j in range(CV_K*CV_N):
for k in range(rankings.shape[1]):
......@@ -94,4 +96,4 @@ for k in range(2, N_LAYERS + 1):
sorted_means = sorted(means.items(), key=operator.itemgetter(1))
borda_df = pd.DataFrame(sorted_means, columns=['FEATURE_NAME', 'MEAN_POS'])
borda_df.to_csv(f"{OUTFOLDER}/{DATASET}/{TARGET}/__Borda_allSpilts_{MODE}_{layers_concat}.txt", sep='\t', index=False, float_format="%.3f")
\ No newline at end of file
borda_df.to_csv(f"{OUTFOLDER}/{DATASET}/{TARGET}/{MODEL/}Borda_allSplits_{MODE}_{layers_concat}.txt", sep='\t', index=False, float_format="%.3f")
\ No newline at end of file
......@@ -27,6 +27,7 @@ parser = myArgumentParser(
parser.add_argument('--outfolder', type=str, help='Results folder')
parser.add_argument('--dataset', type=str, help='Dataset name')
parser.add_argument('--target', type=str, help='Clinical endpoint')
parser.add_argument('--model', type=str, help='classifiers implemented, randomForest or LSVM')
parser.add_argument('--layers', type=str, nargs='+', help='')
parser.add_argument('--n_splits', type=int, help='')
parser.add_argument('--mode', type=str, help='juxt, rSNF, rSNFi, single')
......@@ -37,13 +38,14 @@ args = parser.parse_args()
OUTFOLDER = args.outfolder
DATASET = args.dataset
TARGET = args.target
MODEL = args.model
LAYERS = args.layers
N_SPLITS = args.n_splits
MODE = args.mode
assert MODE in ['juxt', 'rSNF', 'rSNFi', 'single']
#%%
PATH = f'{OUTFOLDER}/{DATASET}/{TARGET}'
PATH = f'{OUTFOLDER}/{DATASET}/{TARGET}/{MODEL}'
N_LAYERS = len(LAYERS)
......@@ -69,15 +71,15 @@ for k in range(2, N_LAYERS + 1):
for split_id in range(N_SPLITS):
PATH = f'{OUTFOLDER}/{DATASET}/{TARGET}/{split_id}'
PATH = f'{OUTFOLDER}/{DATASET}/{TARGET}/{MODEL}/{split_id}'
if MODE == 'rSNF':
file_log = os.path.join(PATH, f'{MODE}/{layers_concat}_tr_RandomForest_rankList.log')
file_metrics = os.path.join(PATH,f'{MODE}/{layers_concat}_tr_RandomForest_rankList_allmetrics.txt')
file_metrics = os.path.join(PATH, f'{MODE}/{layers_concat}_tr_RandomForest_rankList_allmetrics.txt')
else:
file_log = os.path.join(PATH, f'{MODE}/{layers_concat}_tr_RandomForest_KBest.log')
file_metrics = os.path.join(PATH,f'{MODE}/{layers_concat}_tr_RandomForest_KBest_allmetrics.txt')
file_metrics = os.path.join(PATH, f'{MODE}/{layers_concat}_tr_RandomForest_KBest_allmetrics.txt')
with open(file_log) as f:
log_content = f.readlines()
......@@ -158,5 +160,5 @@ for k in range(2, N_LAYERS + 1):
df_results = df_results.append(row, ignore_index=True)
df_results.to_csv(f'{OUTFOLDER}/{DATASET}/{TARGET}/metrics_allSplits_{MODE}.txt', sep='\t', index=False)
df_results.to_csv(f'{OUTFOLDER}/{DATASET}/{TARGET}/{MODEL}/metrics_allSplits_{MODE}.txt', sep='\t', index=False)
# %%
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment