Definition
Molecular property prediction is the supervised task of mapping a molecule to a measured or computed property: a quantum-chemical energy, solubility, lipophilicity, binding to a protein target, or toxicity. With graph neural networks the molecule is a graph of atoms (nodes) and bonds (edges), and the prediction is made at graph level. The standard benchmark suites are MoleculeNet (Wu et al., Chemical Science 2018) and the molecular datasets of the Open Graph Benchmark (Hu et al., NeurIPS 2020).
The input usually arrives as a SMILES string such as Oc1ccccc1 (phenol). A toolkit like RDKit parses it into heavy atoms and bonds. Hydrogens are normally kept only as a per-atom count. The output is one number per task: a regression value, or a logit for each of several binary assays.
The task is hard for four reasons. Labelled sets are small: hundreds to tens of thousands of molecules, because every label is an experiment or a DFT calculation. Multi-task assay data has missing labels. Tiny structural edits can flip activity ("activity cliffs"). And the molecules a chemist wants scored next usually come from new chemical series, not the ones already measured.
Before GNNs the standard approach was a fixed fingerprint fed to a random forest or SVM. The most used is ECFP (extended-connectivity fingerprints, Rogers and Hahn, 2010), which hashes circular atom neighbourhoods of radius 2 or 3 into a bit vector. ECFP plus a random forest is still the baseline that every new model must beat.
From molecule to prediction
Each atom gets a feature vector: element (one-hot), degree, formal charge, number of hydrogens, hybridisation, aromaticity, ring membership and chirality. Each bond gets its type (single, double, triple, aromatic), conjugation, ring membership and stereo. A GNN runs rounds of message passing (see Message Passing Neural Networks (MPNN)), a readout pools the atoms, and an MLP head outputs one value per task:
- state of atom after message-passing rounds; the sum may be replaced by a mean or set2set
- number of tasks, e.g. 12 assays in Tox21
- 1 if molecule has a label for task , else 0; missing labels contribute no loss
Model choices are covered in their own articles. Message Passing Neural Networks (MPNN) were designed for QM9. The directed MPNN of Chemprop (Yang et al., 2019) passes messages along directed bonds and never sends a message straight back along the bond it arrived on. Graph Isomorphism Network (GIN) is the usual backbone for pre-training. On QM9, 3D models such as SchNet (Schütt et al., 2017) add interatomic distances. Energies depend on geometry, so this helps a lot there.
Splits and metrics
A random split puts close analogues of each test molecule in the training set. It measures interpolation within known chemical series. A scaffold split removes side chains to get each molecule's Bemis–Murcko scaffold (Bemis and Murcko, 1996): its ring systems plus the linkers between them. It then sorts the scaffold groups by size and fills train (80%) with the largest groups, then validation (10%), then test (10%). The test set therefore holds rare, unseen scaffolds. This is harder and closer to prospective use.
- labelled positives and negatives of one task; AUC is computed per task and then averaged
- predicted score of molecule
For energies, "chemical accuracy" means an error below 1 kcal/mol (about 0.043 eV). For sparse, highly imbalanced assays such as PCBA, average precision is reported instead of ROC-AUC, because a ROC-AUC near 1 can hide poor precision on the rare actives.
| Dataset | Molecules | Tasks | Target | Metric | Split |
|---|---|---|---|---|---|
| QM9 | 133,885 | 12 | DFT quantum properties | MAE | random |
| ESOL | 1,128 | 1 | aqueous solubility | RMSE | random |
| FreeSolv | 642 | 1 | hydration free energy | RMSE | random |
| Lipophilicity | 4,200 | 1 | octanol/water distribution | RMSE | random |
| Tox21 | 7,831 | 12 | toxicity assays | ROC-AUC | random |
| HIV | 41,127 | 1 | inhibits HIV replication | ROC-AUC | scaffold |
| BACE | 1,513 | 1 | BACE-1 inhibition | ROC-AUC | scaffold |
| ogbg-molpcba (OGB) | 437,929 | 128 | bioassays | AP | scaffold |
| ZINC subset | 12,000 | 1 | constrained solubility | MAE | fixed 10k/1k/1k |
Worked example: masked loss and per-task AUC
| Molecule | y_A | p_A | BCE_A | y_B | p_B | BCE_B |
|---|---|---|---|---|---|---|
| 1 | 1 | 0.90 | 0.105 | – | 0.30 | – |
| 2 | 0 | 0.20 | 0.223 | 1 | 0.80 | 0.223 |
| 3 | 1 | 0.60 | 0.511 | 0 | 0.40 | 0.511 |
| 4 | 0 | 0.70 | 1.204 | 0 | 0.20 | 0.223 |
| 5 | – | 0.50 | – | 1 | 0.35 | 1.050 |
| 6 | 0 | 0.10 | 0.105 | – | 0.60 | – |
- 1Masked loss: 9 of 12 entries are labelled. Their BCE terms sum to 4.155, so . Predictions 0.50, 0.30 and 0.60 get no gradient.
- 2AUC, task A: positives {0.90, 0.60}, negatives {0.20, 0.70, 0.10}. Of the 6 pairs, 5 rank the positive higher; only 0.60 < 0.70 fails. AUC = 5/6 = 0.833.
- 3AUC, task B: positives {0.80, 0.35}, negatives {0.40, 0.20}. 3 of the 4 pairs are ordered correctly, since 0.35 < 0.40. AUC = 3/4 = 0.750.
- 4The reported score is the mean over tasks: (0.833 + 0.750)/2 = 0.792.
1from collections import defaultdict2from rdkit.Chem.Scaffolds import MurckoScaffold34def scaffold_split(smiles, frac_train=0.8, frac_valid=0.1):5 groups = defaultdict(list)6 for i, s in enumerate(smiles):7 groups[MurckoScaffold.MurckoScaffoldSmiles(smiles=s, includeChirality=False)].append(i)8 fams = sorted(groups.values(), key=lambda g: (len(g), g[0]), reverse=True) # largest first9 n = len(smiles)10 train, valid, test = [], [], []11 for g in fams:12 if len(train) + len(g) <= frac_train * n:13 train += g14 elif len(train) + len(valid) + len(g) <= (frac_train + frac_valid) * n:15 valid += g16 else:17 test += g18 return train, valid, test1920smiles = ["Oc1ccccc1", "Cc1ccccc1", "Nc1ccccc1", "OC(=O)c1ccccc1", # benzene scaffold21 "OC1CCCCC1", "Cc1cccnc1", "NC(Cc1c[nH]c2ccccc12)C(=O)O", "O=Cc1ccco1"]22print(scaffold_split(smiles)) # ([0, 1, 2, 3, 7, 6], [5], [4])Use when
- +GNNs learn task-specific substructure features instead of a fixed hash.
- +One encoder can serve many tasks through a multi-task head with masked loss.
- +Self-supervised pre-training on unlabelled molecules (Hu et al., ICLR 2020) helps on small datasets.
Avoid when
- −On small datasets, ECFP plus a random forest is often as good or better.
- −2D graphs ignore conformation, and 3D models need reliable geometries.
- −Out-of-distribution generalisation to new scaffolds remains the main gap.
Where it's used
Virtual screening
rank millions of purchasable compounds for activity before any are made
ADMET filters
solubility, permeability, toxicity and metabolic stability flags in lead optimisation
DFT surrogates
QM9-style models predict energies and orbital gaps far faster than the DFT calculation
Check yourself
Why does a scaffold split usually give a lower score than a random split on the same dataset?
Check yourself
In multi-task Tox21 training, how should missing assay labels be handled?
Remember
- ✓Molecule → RDKit graph (atom and bond features) → GNN → permutation-invariant readout → one output per task.
- ✓Multi-task assays use a masked BCE: . Regression uses MAE or RMSE; classification uses ROC-AUC, or AP when actives are rare.
- ✓Benchmarks: QM9 (133,885 molecules), ESOL, FreeSolv, Lipophilicity, Tox21, HIV, BACE, OGB molhiv and molpcba, ZINC.
- ✓A scaffold split groups by Bemis–Murcko scaffold and fills train with the largest groups, so test scaffolds are unseen.
- ✓Random splits overstate accuracy for new chemistry. Average over seeds on small sets.
- ✓ECFP plus a random forest is a strong baseline. 3D models such as SchNet matter for quantum targets.