Fix MajAtN IndexError when the gold is not the first choice#1274
Open
iamsharduld wants to merge 1 commit into
Open
Fix MajAtN IndexError when the gold is not the first choice#1274iamsharduld wants to merge 1 commit into
iamsharduld wants to merge 1 commit into
Conversation
MajAtN.compute set new_doc.choices = [preprocess(g) for g in doc.get_golds()] (length = number of golds) but kept gold_index = doc.gold_index. When the gold is not the first choice (e.g. gold_index=[1] or 2), new_doc.get_golds() indexes beyond the gold-only choices list and raises IndexError. Mirror PassAtK/GPassAtK: preprocess doc.choices and keep gold_index, so new_doc stays internally consistent.
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.
What
MajAtN.computebuilds the scoringDocfrom the preprocessed golds:but keeps the original
gold_index. When the gold is not the first choice,new_doc.get_golds()indexes
choices[gold_index]beyond the gold-only list and raisesIndexError:Fix
Mirror
PassAtK/GPassAtK: preprocessdoc.choicesand keepgold_index, sonew_docisinternally consistent for any
gold_index.Tests
tests/test_unit_base_metrics.py::test_maj_at_n_non_first_gold— majority-correct → 1, majority-wrong→ 0, with
gold_index=[1]. Fails before (IndexError), passes after.