smftools.analysis.compute.ml_splits#

Matrix/table-level split helpers for machine-learning evaluation.

These helpers operate on metadata tables and split indices only. They do not touch AnnData or perform any file I/O.

Functions

build_leave_one_group_out_splits(...[, ...])

Build leave-one-group-out folds from a metadata table.

summarize_split(train_idx, test_idx, ...[, ...])

Summarize a train/test split from row metadata.

validate_disjoint_groups(train_idx, ...)

Return True when the train and test splits do not share any holdout groups.

smftools.analysis.compute.ml_splits.validate_disjoint_groups(train_idx, test_idx, metadata_df, group_col)#

Return True when the train and test splits do not share any holdout groups.

Return type:

bool

smftools.analysis.compute.ml_splits.summarize_split(train_idx, test_idx, metadata_df, label_col, extra_group_cols=None)#

Summarize a train/test split from row metadata.

For binary numeric labels in {0, 1}, also emits n_pos_* and n_neg_* convenience counts.

Return type:

dict

smftools.analysis.compute.ml_splits.build_leave_one_group_out_splits(metadata_df, group_col, label_col, sort_groups=True)#

Build leave-one-group-out folds from a metadata table.

Each fold holds out one unique group_col value as test and uses all remaining rows as train. Folds that do not contain both classes in both train and test are omitted.

Return type:

list[dict]