Fighting Tuberculosis with AI: How Machine Learning Is Identifying New Life-Saving Compounds

Tuberculosis remains one of the world’s deadliest infectious diseases. According to the 2024 WHO report, TB killed more people in 2023 than any other single infectious agent—twice as many as HIV/AIDS—and over 10 million new cases are diagnosed yearly. Making matters worse, multi-drug-resistant (MDR) and extensively drug-resistant (XDR) TB strains are spreading, rendering many existing treatments useless.

The problem is compounded by slow drug development: the last first-line TB drug, rifampicin, was introduced 60 years ago. Newer options like bedaquiline and delamanid have side effects, and traditional high-throughput screening (HTS) for new compounds is expensive and labor-intensive. This is where machine learning steps in—and the new study shows just how powerful it can be.

The Research Goal: Building Better ML Models for Anti-TB Drug Discovery

Past ML studies for TB drug discovery had key gaps: small datasets, limited algorithms, or too few molecular “fingerprints” (ways to represent a molecule’s structure). The team set out to fix this by creating 103 robust ML models using a large, diverse dataset and multiple ML techniques. Their aim? To accurately predict which molecules could act as effective anti-TB agents, cutting down the time and cost of lab testing.

Step 1: Curating and Preparing the Data

To train their models, the researchers started with a goldmine of data from the ChEMBL database—a public resource for biomedical research. They selected 23,791 unique molecules linked to five TB-related targets (proteins or enzymes that TB bacteria rely on to survive).

First, they cleaned the data: removing duplicates, fixing missing values, and standardizing how they measured “activity.” For TB drugs, activity is often measured by the Minimum Inhibitory Concentration (MIC)—the lowest dose that stops bacterial growth. The team classified molecules as “active” if their MIC was ≤10 µM (effective at low doses) and “inactive” if it was higher. This clear label helped the ML models learn to distinguish useful compounds from useless ones.

Step 2: Representing Molecules—The “Fingerprints” That Matter

Molecules are complex, so the team translated their structures into numerical “fingerprints” and “descriptors” that ML models can understand. These representations capture key chemical properties (like size, charge, or atomic arrangement) that affect how a molecule interacts with TB bacteria.

They used six types of representations:

  • Descriptors: RDKitDes (captures physical/chemical traits like molecular weight or charge).
  • Fingerprints: MACCSFP, MorganFP, PairsFP (Atom-pair), PubChemFP, and RDKitFP (each highlights different structural features, like specific atom groups or bonds).

To boost performance, they also tested combinations—pairing each fingerprint with RDKitDes (e.g., RDKitDes + MorganFP). This way, the models got both structural and chemical information, which proved crucial for accuracy.

Step 3: Building and Testing the ML Models

The team tested seven popular ML algorithms—plus two “ensemble” methods that combine multiple models for better results:

1. Base Algorithms (Single Models)

  • Random Forest (RF): Uses multiple decision trees to reduce overfitting.
  • XGBoost: A gradient-boosting algorithm known for speed and accuracy with complex data.
  • Decision Tree (DT): Simple but prone to overfitting.
  • K-Nearest Neighbors (KNN): Classifies molecules based on their “closest neighbors” in the dataset.
  • Gaussian Naive Bayes (GNB): A probabilistic model that assumes features are independent (less effective here).
  • Logistic Regression (LR): A statistical model for binary classification (active/inactive).
  • Artificial Neural Network (ANN): Mimics the human brain to learn complex patterns.

2. Ensemble Methods (Combined Models)

  • Voting: Aggregates predictions from top models (e.g., XGBoost + RF) and picks the most common result.
  • Stacking: Uses a “meta-model” to learn from the predictions of base models, balancing their strengths.

To ensure the models were reliable, the team used 10-fold cross-validation: splitting the data into 10 parts, training on 9, testing on 1, and repeating 10 times. They optimized hyperparameters (like XGBoost’s “max depth” or RF’s “number of trees”) with random search—faster than testing every possible combination.

Key metrics for success:

  • AUC (Area Under ROC Curve): Measures how well the model distinguishes active vs. inactive molecules (1.0 = perfect).
  • Accuracy: Percentage of correct predictions.
  • Recall: Ability to find all active molecules (critical for not missing potential drugs).
  • F1 Score: Balances precision (avoiding false positives) and recall.

The Big Results: Which Models Performed Best?

After rigorous testing, two standouts emerged:

1. Best Single Model: XGBoost + RDKitDes + MorganFP

The XGBoost algorithm, trained on the combined RDKitDes + MorganFP data, outperformed all other single models. On the training set:

  • AUC = 0.8989 (nearly perfect discrimination).
  • Accuracy = 88.28% (most predictions were correct).
  • Recall = 0.5357 (good at finding active molecules).

Why MorganFP? It captures molecular substructures that are often key to binding with TB proteins—paired with RDKitDes’s chemical trait data, it gave the model a complete picture.

2. Best Ensemble Model: Stacking

When the team combined their top four base models (XGBoost, ANN, KNN, RF) into a stacking ensemble, performance got even better—especially on the test set (unseen data, which tests real-world generalization):

  • Accuracy = 90.69% (higher than any single model).
  • AUC = 0.8063 (strong at distinguishing active compounds).
  • False Positive Rate = 0.0537 (hardly any “false alarms”—critical for avoiding wasted lab work).

The voting ensemble also performed well (88.20% accuracy, AUC = 0.8719), making it a reliable backup for scenarios where speed matters.

Why Do These Results Matter? SHAP Explains the “Why”

A big challenge with ML is “black box” predictions—knowing that a molecule is active, but not why. The team solved this with SHAP (SHapley Additive exPlanations), a tool that quantifies how each molecular feature contributes to a model’s prediction.

Using SHAP, they identified 13 key descriptors that drive anti-TB activity, including:

  • NumHeteroatoms: Number of non-carbon/non-hydrogen atoms (affects how molecules bind to TB proteins).
  • PEOE_VSAS: Van der Waals surface area and charge (influences interactions with bacterial enzymes).
  • MinAbsEStateIndex: A measure of molecular reactivity (critical for inhibiting TB growth).

They even validated these findings with two known anti-TB drugs:

  • Moxifloxacin: SHAP showed that substructures labeled “Morgan 497” and “Morgan 650” help it block TB’s DNA replication enzymes.
  • Delamanid: Substructures “Morgan 530” and “Morgan 317” disrupt TB’s cell wall synthesis—exactly how the drug is known to work.

This not only confirms the model’s accuracy but also gives drug designers clear targets: focus on molecules with these key features to boost anti-TB activity.

What’s Next for TB Drug Discovery?

This study is a game-changer for two big reasons:

  1. Scale: With 23,791 molecules and 103 models, it’s far more comprehensive than past work—making its predictions more reliable.
  2. Accessibility: The team shared all their data (from ChEMBL) and code (via Google Drive) so other researchers can build on their work. No more reinventing the wheel.

In practice, this means labs can use these models to screen thousands of potential compounds in silico (on a computer) before testing the best candidates in the lab. This could cut years off drug development—and help fight MDR-TB faster.

Final Thoughts

Tuberculosis is a stubborn enemy, but machine learning is giving us a new weapon. This study shows that AI can not only predict which molecules might work as anti-TB drugs but also explain why—turning “black box” ML into a tool that drug designers can trust.

As the team notes, their models aren’t just for TB: the same approach could be adapted to other infectious diseases, from HIV to COVID-19. In a world where drug resistance is rising, this kind of innovation isn’t just helpful—it’s essential.