Skip to content

Commit 683b2c7

Browse files
committed
Remove dependence on DWS and blackify the code.
1 parent 95a16e3 commit 683b2c7

File tree

6 files changed

+756
-577
lines changed

6 files changed

+756
-577
lines changed

code/hlr_eval.py

+36-31
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
from sklearn.metrics import roc_auc_score
1212
from scipy.stats import spearmanr
1313

14-
from dataworkspaces.lineage import LineageBuilder
14+
# from dataworkspaces.lineage import LineageBuilder
1515

1616

1717
ARGS_REGEX = {
18-
'hlwt': (re.compile(r'hlwt-([^,]*)'), float),
19-
'l2wt': (re.compile(r'l2wt-([^,]*)'), float),
20-
'epochs': (re.compile(r'epochs-([0-9]*)'), int),
21-
'method': (re.compile(r'method-([^,]*)'), str),
22-
'shuffle': (re.compile(r'shuffle-([0-9]*)'), int),
23-
'training_fraction': (re.compile(r'training_fraction-([^,]*)'), float),
24-
'dataset': (re.compile(r',([^,]*)\.preds'), str),
18+
"hlwt": (re.compile(r"hlwt-([^,]*)"), float),
19+
"l2wt": (re.compile(r"l2wt-([^,]*)"), float),
20+
"epochs": (re.compile(r"epochs-([0-9]*)"), int),
21+
"method": (re.compile(r"method-([^,]*)"), str),
22+
"shuffle": (re.compile(r"shuffle-([0-9]*)"), int),
23+
"training_fraction": (re.compile(r"training_fraction-([^,]*)"), float),
24+
"dataset": (re.compile(r",([^,]*)\.preds"), str),
2525
}
2626

2727

@@ -38,47 +38,52 @@ def parse_args(file_name):
3838

3939

4040
def _analysis_worker(op_file):
41-
preds = pd.read_csv(op_file, sep='\t')
41+
preds = pd.read_csv(op_file, sep="\t")
4242
args = parse_args(op_file)
4343

44-
args['MAE'] = np.mean(np.abs(preds['p'] - preds['pp']))
45-
args['AUC'] = roc_auc_score(preds['p'], preds['pp'])
46-
args['COR_p'] = spearmanr(preds['p'], preds['pp'])[0]
47-
args['COR_h'] = spearmanr(preds['h'], preds['hh'])[0]
44+
args["MAE"] = np.mean(np.abs(preds["p"] - preds["pp"]))
45+
args["AUC"] = roc_auc_score(preds["p"], preds["pp"])
46+
args["COR_p"] = spearmanr(preds["p"], preds["pp"])[0]
47+
args["COR_h"] = spearmanr(preds["h"], preds["hh"])[0]
4848

4949
return args
5050

5151

5252
@click.command()
53-
@click.argument('results_dir', type=click.Path())
54-
@click.argument('output_csv', type=click.Path())
55-
@click.option('--debug/--no-debug', default=False, help='Run in single threaded mode for debugging.')
53+
@click.argument("results_dir", type=click.Path())
54+
@click.argument("output_csv", type=click.Path())
55+
@click.option(
56+
"--debug/--no-debug",
57+
default=False,
58+
help="Run in single threaded mode for debugging.",
59+
)
5660
def run(results_dir, output_csv, debug):
5761
"""Read all *.detailed files from RESULTS_DIR, calculate the metrics, and
5862
save output to OUTPUT_CSV."""
59-
op_files = glob.glob(os.path.join(results_dir, '*.preds'))
60-
61-
builder = (
62-
LineageBuilder()
63-
.as_script_step()
64-
.with_parameters({
65-
'results_dir': results_dir,
66-
})
67-
.with_input_paths(op_files)
68-
)
69-
70-
with builder.eval() as lineage:
63+
op_files = glob.glob(os.path.join(results_dir, "*.preds"))
64+
65+
# builder = (
66+
# LineageBuilder()
67+
# .as_script_step()
68+
# .with_parameters({
69+
# 'results_dir': results_dir,
70+
# })
71+
# .with_input_paths(op_files)
72+
# )
73+
74+
# with builder.eval() as lineage:
75+
if True:
7176
if debug:
7277
data = [_analysis_worker(op_file) for op_file in op_files]
7378
else:
7479
with MP.Pool() as pool:
7580
data = pool.map(_analysis_worker, op_files)
7681

7782
pd.DataFrame(data).to_csv(output_csv, index=False)
78-
lineage.add_output_path(output_csv)
83+
# lineage.add_output_path(output_csv)
7984

80-
print('Done.')
85+
print("Done.")
8186

8287

83-
if __name__ == '__main__':
88+
if __name__ == "__main__":
8489
run()

0 commit comments

Comments
 (0)