MCPcopy Create free account
hub / github.com/FlyingFeather/DEA-SQL / main

Function main

evaluation/test-suite-sql-eval/evaluate_classical.py:99–117  ·  view source on GitHub ↗
(preds: List[str], gold_file: str = "classical_test.pkl", verbose: bool = True,
         num_processes: int = NUM_PROCESSES, subset: str = 'full', use_cache: bool = True)

Source from the content-addressed store, hash-verified

97
98
99def main(preds: List[str], gold_file: str = "classical_test.pkl", verbose: bool = True,
100 num_processes: int = NUM_PROCESSES, subset: str = 'full', use_cache: bool = True) -> List[bool]:
101 gold_dicts = pkl.load(open(gold_file, 'rb'))
102 if subset != 'full':
103 gold_dicts = [d for d in gold_dicts if d['db_path'] == 'database/{db_id}/{db_id}.sqlite'.format(db_id=subset)]
104 assert len(gold_dicts) == len(preds), 'number of gold and prediction should be equal'
105 group_name2idxes = defaultdict(list)
106
107 for idx, gold_dict in enumerate(gold_dicts):
108 group_name2idxes[gold_dict['db_id']].append(idx)
109
110 with Pool(num_processes) as pool:
111 result = list(tqdm.tqdm(pool.imap(judge, zip(gold_dicts, preds, repeat(use_cache, len(preds)))), total=len(gold_dicts)))
112
113 if verbose:
114 print('overall accuracy: ', acc(result))
115 for group, idxes in group_name2idxes.items():
116 print('accuracy for ', group, acc(result, idxes))
117 return result
118
119
120if __name__ == "__main__":

Callers 1

Calls 2

accFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected