You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LearningCurveSplitter: option to keep sessions with too few trials in a per_class curve #1371
With policy="per_class", a size above the smallest class in a session's training pool raises ValueError (_get_data_size_subsets). Folds are built for the whole dataset before any fit, so one short session stops that dataset's evaluation.
A real case: MOABB loads 45 trials per class for Zhou2016's subject 2, session 1, where the other sessions of subjects 1–2 have 50 or more. With test_size=0.2, a grid that reaches 40 works on the 50-trial sessions and raises on that one.
When sessions or datasets differ in trials per class, a learning curve has three choices today:
Stop the grid at the smallest session: no large sizes for anyone.
Use a grid per dataset: the large sizes average fewer sessions, so the curve moves with who is in the average as well as with the training size.
Use policy="ratio": every session stays, but the x-axis is no longer in trials.
develop at 6f7b2eb45 | sklearn 1.6.1 | numpy 2.4.6
ValueError: Smallest class has 36 samples. Desired samples per class 40 is too large.
Proposal
An opt-in clip.LearningCurveSplitter(..., on_few_trials="clip") trains on min(value, smallest class) per class instead of raising. The default, "raise", keeps today's behaviour. The name follows MNE's on_few_samples and NumPy's mode="clip"; another is fine.
A result column with the requested size.data_size records the actual training-set size: per_class values 10, 20, 36 give data_size 20, 40, 72, so a clipped session would land on a different x. The same column helps ratio: sessions with 45 and 60 trials per class get data_size 36, 72 and 48, 96 for ratios 0.5 and 1.0, and the ratio is not in the results.
Every session then contributes to every point, the axis stays in trials per class, and data_size shows which points were clipped.
Activity
ENH add on_few_trials and data_size_value to LearningCurveSplitter