in scripts/adapet/ADAPET/utilcode.py [0:0]
def write_seed_output(pretrained_weight, task_name, sample_size, ds_seed, metric, english, prompt):
dataset = task_name[7:] #remove setfit/
if dataset in ["toxic_conversations"]:
json_dict = {"measure": "ap", "score": metric}
elif dataset in ["amazon_counterfactual_en"]:
json_dict = {"measure": "matthews_correlation", "score": metric}
elif 'SetFit/' + dataset in AMZ_MULTI_LING:
json_dict = {"measure": "mean_absolute_error", "score": metric}
else:
json_dict = {"measure": "acc", "score": metric}
if 'microsoft/' in pretrained_weight:
pretrained_weight = pretrained_weight.replace('microsoft/', '')
if task_name in SINGLE_SENT_DATASETS:
writefile = 'seed_output/' + pretrained_weight +'/'+ dataset +'/'+ 'train-'+str(sample_size)+'-'+str(ds_seed)+ '/'
else:
if english:
lang = 'eng'
else:
lang = 'lang'
if prompt:
prompting = 'prompt'
else:
prompting = 'no-prompt'
writefile = 'seed_output/' + pretrained_weight + "__"+lang+'_'+prompting +'/'+ dataset +'/'+ 'train-'+str(sample_size)+'-'+str(ds_seed)+ '/'
if not os.path.exists(writefile):
os.makedirs(writefile)
writefile = writefile+'results.json'
with open(writefile, "a") as f:
f.write(json.dumps(json_dict))