| |
| from __future__ import annotations |
|
|
| import argparse |
| from pathlib import Path |
|
|
| from benchpress_eval.data import load_dataset |
| from benchpress_eval.io import read_table, write_csv |
| from benchpress_eval.metrics import align_predictions |
| from benchpress_eval.salience import compute_noedit_salience |
|
|
|
|
| def main() -> None: |
| parser = argparse.ArgumentParser( |
| description="Compute no-edit AUROC stratified by ground-truth edit parameters." |
| ) |
| parser.add_argument("--dataset-root", required=True) |
| parser.add_argument("--predictions", required=True) |
| parser.add_argument("--out-dir", required=True) |
| parser.add_argument("--score-col", default=None) |
| parser.add_argument("--bins", type=int, default=5) |
| args = parser.parse_args() |
|
|
| out_dir = Path(args.out_dir) |
| dataset = load_dataset(args.dataset_root) |
| predictions = read_table(args.predictions) |
| aligned = align_predictions(dataset, predictions, score_col=args.score_col) |
| by_bin, summary = compute_noedit_salience(dataset, aligned, n_bins=args.bins) |
|
|
| write_csv(by_bin, out_dir / "salience_by_parameter_bin.csv") |
| write_csv(summary, out_dir / "salience_summary.csv") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|