Repository navigation
Validate metric inputs and correct metric docs - #109
Merged
kPsarakis merged 1 commit intoOct 30, 2026
Merged
Conversation
Ground truth: - accept any iterable (sets raised TypeError; a generator was seen only by the first metric) and count duplicate entries once (they were counted twice in recall but once in precision) - raise ValueError for entries mixing column-name pairs with ColumnPair (one order silently compared table names as column names, the other raised IndexError) or with other than 2 or 4 fields - RecallAtSizeofGroundTruth sizes its cutoff from the deduplicated ground truth Other inputs: - PrecisionTopNPercent raises for n outside 0-100 instead of clamping silently, and uses a fractional n as given instead of truncating it while reporting the fraction in its name - take_top_n() rejects negative n, take_top_percent() rejects values outside 0-100 (negative values sliced from the end) - get_metrics() rejects an unknown one_to_one_method up front, even when no metric uses 1:1 selection Docs: - describe the 1:1 selectors' default threshold accurately: it is at or below the median of the distinct scores, not the median - MeanReciprocalRank averages over ground-truth source columns using per-source rank, as the code does - note how column-name ground truth behaves with more than two tables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix/one-to-one-tied-scores #109 +/- ##
==============================================================
+ Coverage 95.27% 95.29% +0.02%
==============================================================
Files 53 53
Lines 2833 2846 +13
Branches 443 448 +5
==============================================================
+ Hits 2699 2712 +13
Misses 83 83
Partials 51 51
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Stack: 3 of 3. #106 → #107 → this PR. Based on #107, so the diff shows only this change. Merge #106 and #107 first.
Smaller problems found while investigating #105, each reproduced before fixing.
Ground truth
setraisedTypeError: 'set' object is not subscriptable. A generator was consumed by the first metric, so the others saw empty ground truth.get_metrics()now materialises it once.[("a","a"), ("a","a"), ("b","b")]was counted twice in recall but once in precision, giving Recall 2/3 instead of 1/2.RecallAtSizeofGroundTruthnow sizes its cutoff from the deduplicated ground truth.ValueError. The format was decided from the first entry only. Column-name pair first, then aColumnPair: theColumnPairwas compared as(table, column)and silently counted as a miss. The other order raisedIndexError. Entries with other than 2 or 4 fields also raise.Other inputs
PrecisionTopNPercent: raises fornoutside 0–100. Previouslyn=150was reported as"PrecisionTop150Percent"but computed at 100%. A fractionalnis now used as given;n=12.5used to compute with 12 while its name said 12.5.take_top_n(): rejects a negativen.take_top_n(-1)used to drop the last item.take_top_percent(): rejects values outside 0–100.take_top_percent(-50)used to keep 2 of 3.get_metrics(): rejects an unknownone_to_one_methodup front. It was silently accepted when no metric used 1:1 selection.Docs
docs/results.mdcalled it "the median". It's the distinct score at indexceil(k/2)from the top, which is at or below the median; with 3 distinct scores it's the lowest. I documented the existing rule rather than changing it, since a change would shift every published score.MeanReciprocalRank: the docstring now says it averages per ground-truth source column using per-source rank. That's what the code computes and whatdocs/metrics.mdalready said.docs/metrics.md:PrecisionTopNPercent(n=...)Compatibility
The new
ValueErrors replace silently wrong results or unrelated errors, and they're listed under Changed in the changelog.Tests
New
TestGroundTruthInputandTestTopSelectionValidationintests/test_metrics.py. 13 of these tests and subtests fail on #107 without this change. Full suite: 327 passed locally.🤖 Generated with Claude Code