Repository navigation
Conversation
Spread the len % k remainder over the first folds instead of dropping it, and add coverage tests for n % k != 0 and the shipped dataset. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Closes #14
What I changed
mess_mood/evaluate.py:k_foldno longer drops the lastlen(rows) % krows. The remainder is spread over the first folds, so fold sizes arelen // kor one more. The seeded shuffle and the train/test partition (train is every row outside the test slice) are unchanged.tests/test_mess_mood.py: two coverage tests. One usesn % 5 != 0(21, 23, 24, 7) and checks every row is in exactly one test fold and that train and test partition the data. The other does the same for the 113 shipped reviews and checks fold sizes differ by at most one. Both fail onmain.python -m mess_mood evaluatewas computed over 110 of the 113 reviews. It now uses all 113, so the number moves slightly: 83% before, 82% after. Split accuracy (91%) is unchanged.How it works
k_foldusedfold_size = len(rows) // kand slicedrows[i*fold_size:(i+1)*fold_size], so the lastlen(rows) % krows (3 of 113) were never in any test slice. Now I takedivmod(len(rows), k)and make the firstextrafolds one row bigger, walking a runningstart/endindex through the shuffled list. The k slices therefore tile the whole list exactly once, which gives the "every review is in exactly one test fold" promise from the README. When the length divides evenly nothing changes.Testing
pytest: 15 passed (13 existing + 2 new). The new tests fail onmain(2 failed) and pass on this branch.