Sdm0 commited on
Commit
cded1f7
·
verified ·
1 Parent(s): d8c491c

Deploy 95004542

Browse files
Files changed (1) hide show
  1. eval_data/code_review_bench_eval.py +13 -3
eval_data/code_review_bench_eval.py CHANGED
@@ -56,7 +56,7 @@ def main() -> None:
56
  repo_type="dataset",
57
  )
58
  rows = pq.read_table(offline_path).to_pylist()
59
- totals = {"rows": 0, "gold_findings": 0, "pred_findings": 0, "matched": 0, "false_positives": 0, "missed": 0}
60
  failures = []
61
  for row in rows:
62
  if args.max_rows and totals["rows"] >= args.max_rows: break
@@ -71,14 +71,24 @@ def main() -> None:
71
  if i in used: continue
72
  score, ok = match(finding, target)
73
  if ok and (best is None or score > best[0]): best = (score, i)
74
- if best: used.add(best[1]); matched += 1
 
 
 
 
 
 
75
  totals["rows"] += 1; totals["gold_findings"] += len(gold); totals["pred_findings"] += len(generated); totals["matched"] += matched
76
  totals["false_positives"] += len(generated) - matched; totals["missed"] += len(gold) - matched
77
  if len(generated) - matched or len(gold) - matched:
78
  failures.append({"task_id": key, "gold": len(gold), "predicted": len(generated), "matched": matched})
79
  precision = totals["matched"] / totals["pred_findings"] if totals["pred_findings"] else 0.0
80
  recall = totals["matched"] / totals["gold_findings"] if totals["gold_findings"] else 0.0
81
- result = {**totals, "precision": precision, "recall": recall, "f1": 2*precision*recall/(precision+recall) if precision+recall else 0.0, "failures": failures}
 
 
 
 
82
  args.output.write_text(json.dumps(result, indent=2), encoding="utf-8")
83
  print(json.dumps({k: result[k] for k in ("rows","precision","recall","f1","false_positives","missed")}, indent=2))
84
 
 
56
  repo_type="dataset",
57
  )
58
  rows = pq.read_table(offline_path).to_pylist()
59
+ totals = {"rows": 0, "gold_findings": 0, "pred_findings": 0, "matched": 0, "false_positives": 0, "missed": 0, "severity_correct": 0, "category_correct": 0}
60
  failures = []
61
  for row in rows:
62
  if args.max_rows and totals["rows"] >= args.max_rows: break
 
71
  if i in used: continue
72
  score, ok = match(finding, target)
73
  if ok and (best is None or score > best[0]): best = (score, i)
74
+ if best:
75
+ used.add(best[1]); matched += 1
76
+ target = gold[best[1]]
77
+ if finding.get("severity") and target.get("severity") and str(finding["severity"]).lower() == str(target["severity"]).lower():
78
+ totals["severity_correct"] += 1
79
+ if finding.get("category") and target.get("category") and str(finding["category"]).lower() == str(target["category"]).lower():
80
+ totals["category_correct"] += 1
81
  totals["rows"] += 1; totals["gold_findings"] += len(gold); totals["pred_findings"] += len(generated); totals["matched"] += matched
82
  totals["false_positives"] += len(generated) - matched; totals["missed"] += len(gold) - matched
83
  if len(generated) - matched or len(gold) - matched:
84
  failures.append({"task_id": key, "gold": len(gold), "predicted": len(generated), "matched": matched})
85
  precision = totals["matched"] / totals["pred_findings"] if totals["pred_findings"] else 0.0
86
  recall = totals["matched"] / totals["gold_findings"] if totals["gold_findings"] else 0.0
87
+ result = {**totals, "precision": precision, "recall": recall, "f1": 2*precision*recall/(precision+recall) if precision+recall else 0.0,
88
+ "severity_accuracy": totals["severity_correct"] / totals["matched"] if totals["matched"] else 0.0,
89
+ "category_accuracy": totals["category_correct"] / totals["matched"] if totals["matched"] else 0.0,
90
+ "false_positive_rate": totals["false_positives"] / totals["pred_findings"] if totals["pred_findings"] else 0.0,
91
+ "failures": failures}
92
  args.output.write_text(json.dumps(result, indent=2), encoding="utf-8")
93
  print(json.dumps({k: result[k] for k in ("rows","precision","recall","f1","false_positives","missed")}, indent=2))
94