univi.preprocessing.split_by_label

Contents

univi.preprocessing.split_by_label#

univi.preprocessing.split_by_label(labels, *, train_fraction=0.8, val_fraction=0.1, train_cap=None, val_cap=None, max_per_label=None, seed=0)[source]#

Stratify cells; capped training/validation leftovers go to the test set.

max_per_label caps the pool before allocating train/validation fractions, and adds overflow to test (the unused_to_test=True convention used in the article’s CITE-seq and Multiome analyses). It is mutually exclusive with caps applied directly to training and validation counts. The split is deterministic for a given seed. Very small classes may be absent from validation.