Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧬 AMR-Predictor-ML: Machine Learning for Meropenem Resistance in Klebsiella pneumoniae

Python 3.10+ XGBoost Scikit-Learn

📖 Project Overview

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.

🎯 Key Objectives

  • 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.

📊 Dataset

  • 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).

🛠️ Machine Learning Pipeline

The project is structured into 6 main phases documented in Jupyter Notebooks:

  1. 01_data_exploration.ipynb: Exploratory Data Analysis (EDA) and phenotype distribution.
  2. 02_data_preprocessing.ipynb: Target encoding and genomic sequence scaling.
  3. 03_baseline_modeling.ipynb: Establishing baselines with Random Forest and XGBoost.
  4. 04_feature_selection.ipynb: Dimensionality reduction (4,096 ➡️ 500 features) using SelectKBest.
  5. 05_model_optimization.ipynb: Applying scale_pos_weight (1.65) to penalize False Negatives.
  6. 06_interpretability_deployment.ipynb: Extracting Top 20 biological K-mer motifs and saving the .pkl model.

🏆 Final Model Performance (Champion Model)

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)

Biological Interpretability

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.

🌐 Web Application (Streamlit)

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:

  1. Ensure all dependencies are installed (pip install streamlit biopython joblib pandas xgboost).
  2. Run the following command in your terminal:
    streamlit run app.py

About

A Machine Learning pipeline using Python (XGBoost & Random Forest) to predict Meropenem resistance in 3,000+ Klebsiella pneumoniae strains directly from bacterial genomic data.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages