Antimicrobial Resistance (AMR) is one of the top global public health threats. This project leverages Machine Learning to predict Meropenem (a last-resort antibiotic) resistance in Klebsiella pneumoniae directly from genomic data. By extracting 6-mer DNA motifs and applying an optimized, cost-sensitive XGBoost model, we decode the genomic signatures of resistance.
- Formulate AMR prediction as a binary classification problem (Susceptible vs. Resistant).
- Handle the "Curse of Dimensionality" using statistical feature selection (ANOVA F-Test).
- Address extreme class imbalance using Cost-Sensitive Learning to maximize the detection of resistant strains (Recall).
- Interpret the biological relevance of the model's top predictive K-mers.
- Source: Derived from the PATRIC (Pathosystems Resource Integration Center) database.
- Samples: 2,836 complete bacterial genomes.
- Features: 4,096 genomic 6-mer frequencies + 5 metadata columns.
- Target:
AMR_Label(0 = Susceptible, 1 = Resistant).
The project is structured into 6 main phases documented in Jupyter Notebooks:
01_data_exploration.ipynb: Exploratory Data Analysis (EDA) and phenotype distribution.02_data_preprocessing.ipynb: Target encoding and genomic sequence scaling.03_baseline_modeling.ipynb: Establishing baselines with Random Forest and XGBoost.04_feature_selection.ipynb: Dimensionality reduction (4,096 ➡️ 500 features) using SelectKBest.05_model_optimization.ipynb: Applyingscale_pos_weight(1.65) to penalize False Negatives.06_interpretability_deployment.ipynb: Extracting Top 20 biological K-mer motifs and saving the.pklmodel.
Our best-performing model is the Cost-Sensitive XGBoost trained on all 4,096 features. It successfully balanced general accuracy with a highly penalized recall for the resistant class.
- Global Accuracy:
70.25% - ROC-AUC Score:
75.31% - Resistant Recall:
59%(Improved from 35% baseline)
The model identified C-rich and G-rich motifs (e.g., CACCCC, CCCCTG) as the top predictive features. These motifs are strongly correlated with plasmid and transposon regions, which are the primary vehicles for AMR genes (like blaKPC or blaNDM) in K. pneumoniae.
This project includes a production-ready web interface where users can upload real Klebsiella pneumoniae FASTA files to get instant Meropenem resistance predictions. https://refmyoussef-source-amr-predictor-ml-app-t1fzud.streamlit.app/
To run the app locally:
- Ensure all dependencies are installed (
pip install streamlit biopython joblib pandas xgboost). - Run the following command in your terminal:
streamlit run app.py