Repository navigation
FIX keep CrossSession results session-specific for custom CV folds - #1210
Conversation
|
Exact-head validation is green on |
|
Updated exact-head validation: on |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@bruAristimunha this is the smallest independent piece of the evaluation-provenance series and is ready for review. It only fixes CrossSession custom-CV folds that hold out multiple sessions: one fit is retained, but scoring/result attribution stays session-specific, with legacy/parallel parity covered. It does not depend on #1207/#1211, so it can merge independently; I’ll keep this head frozen unless review finds an issue. |
bruAristimunha
left a comment
There was a problem hiding this comment.
Thanks @lindicaphxag-tech. The fix is well scoped to CrossSessionEvaluation; the default LeaveOneGroupOut path still produces one row per fold since every fold holds exactly one session (the np.unique(test_sessions) loop collapses to one iteration), and the GroupKFold(n_splits=2) regression checks that the flattened and legacy paths agree on keys, scores and n_samples_test. I've just approved the Actions run; I'll approve the PR once Test/Test-braindecode are green on 150ada9. One request: since the flattened path previously returned one aggregated row per fold and now one per held-out session, please mention it under API changes in whats_new.rst as well.
bruAristimunha
left a comment
There was a problem hiding this comment.
CI is green on 150ada9 (Test matrix, Test-braindecode, Docs). Approving — please still add the whats_new API note about one row per held-out session for custom folds before merge if you get a chance, @lindicaphxag-tech. Thanks.
Summary
CrossSessionEvaluationsupports arbitrary scikit-learncv_classvalues, so a custom test fold can contain more than one recording session. The current scoring path still assumes each fold holds out exactly one session and labels the entire fold withgroups[test][0].That silently gives multi-session folds the provenance of whichever session appears first.
Context in the evaluation-safety series
This is a follow-up found while validating the custom-CV path around #1207. #1207 makes explicit top-level splitters usable; this PR closes the corresponding result-provenance invariant for
CrossSessionEvaluation: once a custom fold may contain multiple sessions, result rows must still remain session-specific rather than inheriting the first group label.Fix
Keep fitting once per CV fold, but score and store each held-out session separately.
score_per_sessionmachinery, which already implements the same grouping;Regression coverage
A focused test uses
GroupKFold(n_splits=2)on a 4-session, 2-subject fake dataset. Each CV fold therefore holds out two sessions at once. It verifies that:n_samples_testis session-specific;No splitter API or grouping semantics are changed.