Repository navigation
Fix CrossSubjectEvaluation crash when n_splits and random_state are both set - #1374
Open
ptlnextdoor wants to merge 1 commit into
Open
ptlnextdoor wants to merge 1 commit into
ptlnextdoor wants to merge 1 commit into
Conversation
GroupKFold accepts random_state but rejects it while shuffle is False, so CrossSubjectEvaluation(n_splits=k, random_state=s) raised ValueError. The splitter now skips the seed in that case, as CrossSessionSplitter already does.
This branch has not been deployed
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 was wrong
CrossSubjectEvaluation(n_splits=k, random_state=s)raisedValueError: Setting a random_state has no effect since shuffle is False.Withn_splitsset, the inner CV isGroupKFold. Since scikit-learn 1.6,GroupKFoldhas arandom_stateargument but refuses a seed whileshuffle=False.CrossSubjectSplitterpassedrandom_statewhenever the class accepts it. Without a seed the same call worked.What changed
moabb/evaluations/splitters.py:CrossSubjectSplitterno longer passesrandom_stateto a CV class that has ashuffleargument which is off. The folds are the same as without a seed.CrossSessionSplitteralready guards the same case.moabb/tests/test_evaluations.py: a regression test builds the splitter fromCrossSubjectEvaluation(n_splits=2, random_state=42)onFakeDatasetand checks that it makes 2 folds identical to the unseeded ones. It fails on develop with theValueErrorabove.docs/source/whats_new.rst: one line under Bugs.How tested
pytest moabb/tests/test_evaluations.py: the new test fails on develop and passes with the change (scikit-learn 1.9.1).pre-commit run --fileson the three changed files: pass.AI disclosure: this PR was prepared with AI assistance (Claude, Anthropic).