
Antimicrobial resistance (AMR) prediction from bacterial genomic data is frequently confounded by clonal population structure, whereby machine learning models learn strain lineage rather than the causal genetic determinants of resistance. We present a benchmarking pipeline that explicitly addresses this confound through lineage-group-aware cross-validation and kinship-based population structure correction, and we evaluate it on a real-world dataset of 1,930 Escherichia coli isolates characterized by 17,198 accessory genome features, with ciprofloxacin (CIP) susceptibility as the prediction target (428 resistant, 1,502 susceptible).
Using StratifiedGroupKFold cross-validation (grouped by 337 multilocus sequence type [MLST]-based lineages) and kinship principal components (PCs) as covariates, we compared three model classes: L2-regularized logistic regression with kinship PCs, gradient-boosted trees (LightGBM) with Bayesian hyperparameter optimization (Optuna), and an FT-Transformer deep learning architecture trained with a snapshot ensemble.
Enforcing true lineage-level grouping, rather than isolate-level grouping, substantially reduced apparent discrimination relative to a naively evaluated pipeline and increased fold-to-fold variance – a pattern consistent with the removal of lineage leakage rather than a weakness of the method. These results indicate that gradient-boosted tree ensembles retain a statistically confirmed advantage over a regularized linear baseline for sparse, high-dimensional, moderate-sample-size bacterial genomic prediction tasks under rigorous leakage control, and yield a tractable candidate gene set for downstream experimental validation.
The complete Python pipeline, including PyTorch (FT-Transformer), LightGBM, Optuna, and scikit-learn implementations, is openly available on GitHub:
🔗 https://github.com/AqilaThe…