Repository navigation
test: improve bulk accuracy scoring + paired before/after comparison - #379
Merged
Merged
Conversation
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>
garobrik
approved these changes
Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.What
soil_id/tests/bulk_match.py— shared normalized matching (trailing-s, optional last-word),best_rank, andrecall@ksummary. Unit-tested intest_bulk_match.py.th_taxonname_1..5classification history; reports recall@1/3/5.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)
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