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 folds from a metadata table. |
|
Summarize a train/test split from row metadata. |
|
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:
- 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 emitsn_pos_*andn_neg_*convenience counts.- Return type:
- 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_colvalue as test and uses all remaining rows as train. Folds that do not contain both classes in both train and test are omitted.