Skip to content

Refuse duplicate predictions in analyze; keep excluded outputs in prompts - #309

Draft
MaxGhenis wants to merge 3 commits into
mainfrom
lane/analyze-duplicates-and-prompts
Draft

MaxGhenis wants to merge 3 commits into
mainfrom
lane/analyze-duplicates-and-prompts

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Fixes #287, #288 and #285, three follow-ups from the reviews of #280 and #281.

Tests:

  • test_analyze_rejects_duplicate_prediction_rows: refuses before any output is written.
  • test_export_preserves_combined_predictions_when_by_model_rows_repeat: the earlier predictions.csv is left byte for byte.
  • test_analyze_prompts_keep_fully_excluded_outputs_in_reference_order: checks both prompt contracts.

A Codex lane (GPT-6.2 Sol) wrote the patch, and Claude read it against main before applying it. The tests were not run locally; CI runs pytest -m "not slow". ruff check and ruff format --check pass on the changed files.

🤖 Generated with Claude Code

…mpts

- policybench analyze applies the exporter's (model, scenario_id,
  variable) uniqueness check to its predictions before scoring, so a
  duplicated row can no longer count twice in the aggregates (#287).
- load_predictions checks the combined per-model rows before writing
  predictions.csv, so a refused export no longer replaces a valid file
  (#288).
- analyze builds its prompt map from the reference's variables before
  exclusions are split out, in reference order, as export_country does
  (#285).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policybench-site Ready Ready Preview Dec 3, 2026 5:29am UTC

Request Review

analyze --runs-dir now rejects a duplicate (run_id, model, scenario_id,
variable) row before scoring, so a repeated prediction can no longer
inflate within10pct_run_mean. The repeat loader is imported only when
--runs-dir is given.

export-full-run reads model, scenario_id and variable as strings in every
prediction shard and in the reference, scenario and annotation CSVs they
join against. A scenario id parsed as 1 in one shard and "1" in another
can no longer slip past the duplicate check.

The export duplicate test clears the reasoning-effort override so it does
not depend on the caller's environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 2 found that analyze could still score duplicate predictions when
CSV type inference gave one key two types: a run file named 1.csv with
no run_id column got the string "1", while a file declaring run_id=1
got the integer 1, so the per-run guard saw two runs. analyze now reads
predictions, the reference and the scenario manifest with the shared
string key dtypes, and load_repeated_predictions reads run_id, explicit
or taken from the file name, as a string. run_id stays in the repeat key,
so distinct runs can still score the same target.

Padded numeric scenario ids such as 001 now survive the bound prediction
readers in finish_terra.py and finish_fable52.py and the audit's
manifest read, so a correct prediction is no longer marked missing and a
genuine miss keeps its question.

Tests: the repeat test covers a duplicate within one file, the same run
split across a file name and a run_id column (refused), and two distinct
runs (accepted, run count 2). A new analyze test keeps 001 and 1 apart.
A new audit test covers padded ids with the default and both bound
readers. The primary duplicate test now uses an importable stub for the
repeat loader and asserts the scorer never runs, and the prompt test
clears the reasoning-effort override.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 5e49ee85 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write the combined predictions file only after the duplicate check Refuse duplicate prediction rows in policybench analyze

1 participant