Calculate class-balanced train and test set sizes using stratified sampling.
Stratified sampling applies the same train percentage independently to each class, so class_n_train = class_n_total × train%, ensuring every class contributes proportionally to both the train and test sets. This calculator accepts an arbitrary list of per-class totals and produces an exact per-class train/test split, which is the standard approach for classification tasks with multiple classes of varying size.
class_train_n = round(class_total_n × train_percent / 100)
Splitting the whole dataset randomly can under-represent rare classes in one partition purely by chance; splitting within each class guarantees every class is represented proportionally in both sets.
For classes with fewer than ~10 samples, rounding can distort the train percentage significantly — consider merging rare classes or using leave-one-out validation instead.
Run this calculator twice: first split into train vs. (val+test), then split the (val+test) remainder again into val and test using the same method.