New cross subject class for Transfer Learning#1091
Draft
toncho11 wants to merge 8 commits into
Draft
Conversation
…aluation. And an example on how to use 4 of them using RPA (Riemannian Procrustes Analysis).
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.
General description
The code for: #1077
Please take the time to analyze this proposed contribution. A lot of thought/work has been put into it.
This PR proposes a target-aware cross-subject evaluation designed for transfer-learning BCI methods. The main motivation is that some transfer-learning methods need more than ordinary train/test indices: they need to know which training trials belong to which source subject, and in some cases they need controlled access to unlabeled or labeled data from the held-out target subject.
The implementation supports several explicit protocols, also called "modes" here. This makes it possible to evaluate methods such as Riemannian alignment or Riemannian Procrustes Alignment, where unlabeled target data and source-subject identity are needed.
At the same time, the implementation tries to stay as close as possible to MOABB’s existing machinery. It reuses the existing cross-subject structure, data loading, splitting, scoring, result construction, model saving, and pipeline handling wherever possible. The additional logic is limited to the parts that cannot be represented cleanly.
More information:
It provides a leave-one-subject-out (LOSO) evaluation with controlled access to the held-out subject. The held-out subject (HOS) is the target subject being evaluated.
Currently, it provides 6 modes:
HOS_SOURCE_ONLY_TRIALWISE - Source-only training; each held-out target
trial is predicted independently. This mode is
the closest to real-world BCI when we do not
have enough data.
HOS_SOURCE_ONLY_BLOCKWISE - Source-only training; held-out target trials
are predicted as a block, matching standard
MOABB behavior. It is a compatibility mode
with CrossSubjectEvaluation. Do not use it;
use one of the other modes, as they are more
clearly defined.
HOS_UNLABELED_20P - First 20% of held-out target trials are used unlabeled
for adaptation; the remaining 80% are evaluated.
HOS_UNLABELED_50P - First 50% of held-out target trials are used unlabeled
for adaptation; the remaining 50% are evaluated.
HOS_UNLABELED_100P - All held-out target trials are used unlabeled for
transductive adaptation and are also evaluated.
HOS_LABELED_20P - First 20% of held-out target trials are used with labels
for supervised calibration; the remaining 80% are
evaluated.
New fit method looks like this:
Some extra notes:
The code also handles things like HOS_SOURCE_ONLY_TRIALWISE vs HOS_SOURCE_ONLY_BLOCKWISE. HOS_SOURCE_ONLY_BLOCKWISE is the one currently used in CrossSubjectEvaluation, but it is not strict on how benchmarking is performed. HOS_SOURCE_ONLY_BLOCKWISE allows you to both evaluate samples from the held-out subject sample by sample independently or use all the test samples to create for example a Riemannian mean on the test data or learn the distribution on the test data and use this to boost your classification performance. So it is better to use HOS_SOURCE_ONLY_TRIALWISE or HOS_UNLABELED_100P to be sure that the benchmark protocol is explicit.