Fix WithinSession/WithinSubjectSplitter overwriting explicit n_splits in cv_kwargs#1107
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix WithinSessionSplitter overwrite of explicit n_splits
Fix WithinSession/WithinSubjectSplitter overwriting explicit n_splits in cv_kwargs
Jun 27, 2026
…hinSubjectSplitter reproducible - WithinSessionEvaluation/WithinSubjectEvaluation now map the base-class n_splits to the inner n_folds instead of hardcoding 5 folds, matching CrossSubjectEvaluation. - WithinSubjectSplitter.split() reseeds its RNG per call (shared across subjects to preserve the legacy fold sequence) so repeated calls with a fixed random_state are reproducible. - Correct the cv_kwargs docstrings/changelog: only n_splits can be passed through cv_kwargs (shuffle/random_state are named constructor params).
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.
WithinSessionSplitterandWithinSubjectSplitterunconditionally injectedn_folds/shuffle/random_stateinto the inner CV kwargs, clobbering values the caller explicitly passed viacv_kwargs. This made it impossible to request, e.g., a single stratified holdout split without an inner-CV wrapper that hidesn_splits.Changes
moabb/evaluations/splitters.py— In both splitters, only inject then_folds/shuffle/random_statedefaults when the key is absent fromcv_kwargs(if p in params and p not in cv_kwargs). Caller-provided values now take precedence; defaults are unchanged when not supplied.n_splits/shuffle/random_stateincv_kwargsoverride the corresponding constructor arguments.moabb/tests/test_splits.py— Parametrized regression test asserting an explicitn_splits=1survives and produces one split per group for both splitters.docs/source/whats_new.rst— Changelog entry.