Delower commited on
Commit
587bef8
·
verified ·
1 Parent(s): 4122bb2

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +104 -0
README.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - drug-discovery
5
+ - dpp-4
6
+ - binding-affinity
7
+ - pkd
8
+ - cheminformatics
9
+ - pytorch
10
+ library_name: pytorch
11
+ pipeline_tag: tabular-regression
12
+ ---
13
+
14
+ # DPP-4 Kd LTN
15
+
16
+ A tuned **LTN** (Logical Tensor Network-style MLP, PyTorch) that predicts the
17
+ binding affinity **pKd** of a small molecule for **human DPP-4**
18
+ (dipeptidyl peptidase 4; UniProt **P27487**, ChEMBL **CHEMBL284**) from its SMILES.
19
+
20
+ The protein input is fixed to DPP-4: this is a single-target model. For each
21
+ compound it returns predicted **pKd**, **Kd in nM** (= 10^(9 − pKd)),
22
+ **ΔG in kcal/mol** (= −1.3642 × pKd, the ΔG° = −RT·ln10·pKd convention at
23
+ 298.15 K), and a potency class (**potent** pKd ≥ 7, **moderate** 6–7,
24
+ **weak** < 6).
25
+
26
+ ## Model
27
+
28
+ - Architecture: MLP trunk **768 → 384 → 192** (GELU, dropout 0.1) with a
29
+ regression head (pKd) and a 3-class band head. Training loss = MSE(pKd) +
30
+ cross-entropy(band) + (1 − satisfiability of the true-band axiom, p=2
31
+ SatAgg) — the LTN component.
32
+ - Inputs (3,328, no scaling — exactly as trained):
33
+ - Ligand: Morgan fingerprint, radius 2, **2048 bits** (RDKit).
34
+ - Protein: **ESM-2 650M** mean-pooled embedding of full-length human DPP-4,
35
+ **1280 dims**, computed once and reused (bundled in `esm2_dpp4.npz`).
36
+
37
+ ## Training — two-stage transfer
38
+
39
+ 1. **Stage 1 (pretrain):** all-target Kd corpus, **86,569 compound–target
40
+ rows** collected from ChEMBL, BindingDB, PubChem and PDBbind
41
+ (lr 1e-4, batch 256, early stopping). Stage-1 held-out test:
42
+ RMSE 0.8865, R² 0.6969 (n = 8,658).
43
+ 2. **Stage 2 (fine-tune):** all weights fine-tuned on **555 DPP-4 Ki
44
+ compounds** (pKi used as the fine-tune label; lr 5e-5, batch 64, early
45
+ stopping). These stage-2 weights (`ltn_stage2.pt`) are the deployment
46
+ weights in this repo.
47
+ 3. **External evaluation:** the only **15 DPP-4 compounds with measured Kd**
48
+ form the external test set. They were blocked by molecule identity from
49
+ every training stage (overlap verified to be exactly 0).
50
+
51
+ Training ran on UAB Cheaha via SPARCq (suite job 801).
52
+
53
+ ## External test results (15 held-out DPP-4 Kd compounds)
54
+
55
+ | Model | External RMSE (pKd) ↓ | External MAE (pKd) ↓ | Class accuracy ↑ |
56
+ |---|---|---|---|
57
+ | **LTN (this model)** | **1.6037** | **1.2758** | 0.8667 |
58
+ | GAT + ExtraTrees head | 1.6106 | — | — |
59
+ | GAT | 1.6579 | 1.3741 | 0.9333 |
60
+ | Mistral-8L (reduced backbone) | 1.6923 | 1.4679 | 0.9333 |
61
+ | Trees (RandomForest / ExtraTrees) | not present in the retrieved comparison file (empty row) | | |
62
+
63
+ Values are from `kd_model_comparison.csv` (included in this repo). The
64
+ GAT + ExtraTrees head figure is that file's dedicated
65
+ `external15_rmse_extratrees_head` column. Per-compound LTN predictions for
66
+ all 15 compounds are in `external_ltn.csv`; full metrics (including stage-1)
67
+ are in `metrics_ltn.json`.
68
+
69
+ **Verification:** the metrics above were reproduced by live inference from
70
+ the exact weights in this repo on 2026-11-12 — RMSE 1.6037, MAE 1.2758,
71
+ class accuracy 0.8667, and per-compound predictions matching
72
+ `external_ltn.csv` to < 5×10⁻⁵.
73
+
74
+ ## Honest caveats
75
+
76
+ - **External accuracy is modest.** RMSE ≈ 1.6 log units on only n = 15
77
+ compounds, with a systematic **under-prediction bias of −1.10 pKd units**.
78
+ This is a hard transfer problem: the model was fine-tuned on Ki and is
79
+ evaluated on Kd, and 15 compounds is a small test set. Treat predictions
80
+ as a ranking/screening signal, not as measured affinities.
81
+ - Single target only (human DPP-4). The bundled ESM-2 vector is DPP-4's;
82
+ the model cannot score other targets.
83
+ - Research use only; not a substitute for experimental Kd measurement.
84
+
85
+ ## Usage
86
+
87
+ ```bash
88
+ pip install torch rdkit numpy
89
+ python predict_kd.py "Cn1c(=O)cc(N2CCC[C@@H](N)C2)n(Cc2ccccc2C#N)c1=O"
90
+ # pKd 7.7058 | Kd 19.69 nM | dG -10.5123 kcal/mol | potent | (alogliptin)
91
+ python predict_kd.py --csv compounds.csv --smiles-col canonical_smiles --out preds.csv
92
+ ```
93
+
94
+ ## Files
95
+
96
+ | File | Contents |
97
+ |---|---|
98
+ | `ltn_stage2.pt` | Stage-2 (DPP-4 Ki fine-tuned) LTN weights — the deployment model |
99
+ | `predict_kd.py` | Self-contained inference (single SMILES or CSV batch) |
100
+ | `config.json` | Architecture, feature spec, target, provenance, metrics |
101
+ | `esm2_dpp4.npz` | The DPP-4 ESM-2 650M embedding only (slim extract of the project's per-target store) |
102
+ | `external_ltn.csv` | The 15-compound external test grid (experimental vs predicted pKd) |
103
+ | `metrics_ltn.json` | Full metrics: stage-1 val/test + stage-2 external test |
104
+ | `kd_model_comparison.csv` | All-model external comparison from the training run |