Skip to content

test: improve bulk accuracy scoring + paired before/after comparison - #379

Merged
johannesparty merged 2 commits into
mainfrom
test/bulk-accuracy
Sep 26, 2026
Merged

johannesparty merged 2 commits into
mainfrom
test/bulk-accuracy

Conversation

@johannesparty

Copy link
Copy Markdown
Contributor

Makes the bulk accuracy harnesses usable for validating algorithm changes. No algorithm behavior changes — scoring only, so no snapshot regeneration.

Why

The bulk tests already score real ground truth (at what rank does the algorithm place each pedon's known soil?), but two weaknesses made the signal hard to use:

  1. The match was an exact string compare against a single taxonname — badly undercounts hits, because the algorithm returns a series/group name (different taxonomic level), names differ by trailing "s"/case, and a pedon carries several historical classifications.
  2. There was no way to compare two runs, so you couldn't tell whether a change helped or hurt.

What

  • soil_id/tests/bulk_match.py — shared normalized matching (trailing-s, optional last-word), best_rank, and recall@k summary. Unit-tested in test_bulk_match.py.
  • US processor — augments ground truth with the th_taxonname_1..5 classification history; reports recall@1/3/5.
  • Global processor — reports recall@k for strict and lenient (last-word) matching.
  • compare_bulk_test_results.py + make compare_bulk_test_results_{us,global} BEFORE=… AFTER=…** — paired before/after diff: recall@k change, and counts of improved / worsened / newly-found / newly-missing with examples.

How to use (validating a change)

# on the base branch
make generate_bulk_test_results_global   # -> before.jsonl
# on the change branch
make generate_bulk_test_results_global   # -> after.jsonl
make compare_bulk_test_results_global BEFORE=before.jsonl AFTER=after.jsonl

The absolute recall numbers are still noisy (crude match), but the paired delta is trustworthy — the match bias cancels across the two runs. This is the tool for validating the pending global-soil-correctness fixes (esp. the shared US+global imputation change).

Notes

Still a manual, slow harness (thousands of pedons; not in CI). Treat the paired delta as the reliable output, not the absolute percentage.

🤖 Generated with Claude Code

The bulk harnesses score real ground truth (rank of each pedon's known soil), but
the match was an exact string compare against a single taxonname, which badly
undercounts hits, and there was no way to compare two runs. This makes the
accuracy signal usable for validating algorithm changes.

- soil_id/tests/bulk_match.py: shared normalized matching (trailing-'s' + optional
  last-word), best_rank, and recall@k summary. Unit-tested (test_bulk_match.py).
- US processor: augment ground truth with the th_taxonname_1..5 classification
  history; report recall@1/3/5.
- Global processor: report recall@k for strict and lenient (last-word) matching.
- compare_bulk_test_results.py + `make compare_bulk_test_results_{us,global}`:
  paired before/after delta (recall@k change, improved/worsened/newly-found), the
  reliable way to validate a change since the crude-match bias cancels in a pair.

No algorithm behavior changes; scoring only, so no snapshot regen.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Cambisols)

list_soils appends a disambiguation digit to duplicate component names, so
"Calcaric cambisols2" did not match the ground-truth "Calcaric Cambisol" and was
scored as a miss even though the algorithm ranked the right soil. Strip a trailing
digit before matching. (Recovers individual cases; does not materially change the
aggregate before/after delta, which is dominated by real score movement.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@johannesparty
johannesparty merged commit 8164d47 into main Sep 26, 2026
4 checks passed
@johannesparty
johannesparty deleted the test/bulk-accuracy branch September 26, 2026 18:25
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.

2 participants