ML from the beginning: the story and the formulas
Contents
- ML in one paragraph
- Timeline
- 1805–1958: a line, a loss, and the first learning machine
- 1901–2018: finding structure without labels
- 1986–2012: deep learning
- 2014–2020: attention, transformers and diffusion models
- 2007–2022: ML meets atoms
- 2018–2024: ML meets proteins
- What ML cannot see, and how to test a model honestly
- Where the ideas meet my work
- Symbol key
- Glossary: English–中文
- Sources and further reading
ML in one paragraph
Machine learning (ML, 机器学习) builds a function from data instead of from a derivation. You choose a family of functions f(x; θ) with adjustable parameters θ (参数), define a loss function (损失函数) that measures how badly the function fits the data, and let an optimiser (优化器) change θ until the loss is small. Everything else is a choice: what the data are (labelled or not), what the function family is (a straight line, a neural network, a graph of neighbours), and what the loss rewards.
The contrast with the MD note is direct. In MD the function is written down first (the force field, Eqs. 2.9 and 2.11 of my thesis) and the computer works out its consequences. In ML the consequences are given (the data) and the computer works out the function. A force field sits between the two: its form was derived, but its parameters (k_r, ϵ_ij, the partial charges) were fitted to quantum-chemical and experimental data, which is a regression problem. The main limit of ML follows from the definition: a fitted function is only reliable near the data it was fitted on.
| My thesis, §2.3 | Where it appears in this note |
|---|---|
| §2.3 opening: definition of ML; supervised, unsupervised and semi-supervised learning | “1805–1958” (learning with labels) and “1901–2018” (learning without labels) |
| §2.3 opening: deep learning; neurons and layers; CNNs, autoencoders, transformers | “1986–2012” and “2014–2020” |
| §2.3.1 Dimensionality reduction: PCA and UMAP | “1901–2018” |
| §2.3.2 Clustering: HDBSCAN | “1901–2018” |
| §2.3.3 AlphaFold: pLDDT, static snapshots, models as hypotheses | “2018–2024” |
| Not in the thesis: ML interatomic potentials and graph networks | “2007–2022” (my current work) |
| Not in the thesis: train/test splits, overfitting, data leakage | “What ML cannot see” |
How this note is built. My thesis applied these methods and described them in words; §2.3 has no equations. This note sets out the mathematics behind them, in the order it was invented.
- Each chapter is one step in the history, with the formula that step introduced and a plain statement of what the formula says.
- Each chapter opens with In my thesis, which names the section it expands, and ends with Where I use this.
- Thesis references (§, Eq., Fig., ref.) point to my PhD thesis (King’s College London, 2026). Chapter 2 is posted with these notes.
- Chinese terms (中文) are given in brackets at first use and collected in the glossary.
Timeline
Read each road from left to right. Filled marks are the tools I used in my thesis; all five date from 2013 or later. Marks with a dot are methods I am working with now. On the first road the ideas waited decades: backpropagation is from 1986, and AlexNet (2012) is the point where data and GPUs caught up with it.
1805–1958: a line, a loss, and the first learning machine
In my thesis: the opening of §2.3, “Supervised learning”: the model is trained on labelled data, and “the goal is to learn a mapping from inputs to known outputs”.
Supervised learning (监督学习) needs a model, a loss and an optimiser. All three existed before the word “machine learning” did.
1805: least squares (最小二乘法). Adrien-Marie Legendre published the method in 1805. Carl Friedrich Gauss published it in 1809 and said he had used it since 1795; his fit to the few observations of Ceres, discovered on 1 January 1801, let astronomers find it again. The model is a straight line, and the loss is the mean squared error (均方误差). It is the formula behind “a mapping from inputs to known outputs” in §2.3:
Here x_n is the input of example n, written as a list of numbers called features (特征). y_n is the known answer, the label (标签). is the model’s output. The weights (权重) w and the bias (偏置) b are the parameters. Training (训练) means finding the parameters that make the loss L as small as possible. If the label is a number the task is regression (回归); if it is a category the task is classification (分类).
1847: gradient descent (梯度下降法). For a straight line the best parameters can be solved exactly. For any other model they cannot, and Augustin-Louis Cauchy’s method of 1847 is used instead:
θ stands for all the parameters and η is the learning rate (学习率), the size of each step. The gradient ∂L/∂θ points uphill on the loss, so each update moves the parameters downhill. This is the steepest-descent energy minimisation that starts every MD run (§4.2.3 of my thesis), with the loss L in place of the potential energy U and the parameters θ in place of the coordinates. The force of thesis Eq. 2.6, F = −∂U/∂r, is the same downhill direction.
1951: the stochastic version (随机梯度下降, SGD). Herbert Robbins and Sutton Monro introduced stochastic approximation in 1951. In SGD the gradient is computed on a small random batch of the data at each step, not on all of it. Each step is cheap and noisy, and the noise averages out over many steps. Every neural network is trained this way. It is also the “stochastic gradient descent” that optimises the UMAP embedding in §2.3.1 of my thesis.
1958: the perceptron (感知机). Warren McCulloch and Walter Pitts described an artificial neuron (神经元) in 1943. Frank Rosenblatt made one that learns: he simulated the perceptron on an IBM 704 in 1957, published it in 1958, and built it as hardware (the Mark I Perceptron) in 1959–1960. The IBM 704 is the machine type on which Alder and Wainwright ran the first MD in 1957. This is the “neuron” of §2.3:
A neuron is the linear model of 1805 followed by a non-linear activation function (激活函数) σ. In the perceptron σ is a step: the output is 1 if w·x + b is positive and 0 otherwise, so the neuron sorts inputs into two classes. Rosenblatt’s learning rule changed w after each wrong answer, which is SGD applied to one neuron.
1959: the name. Arthur Samuel at IBM, who wrote a program that learned to play checkers, coined the term “machine learning”.
1901–2018: finding structure without labels
In my thesis: §2.3 “unsupervised learning”, §2.3.1 Dimensionality reduction and §2.3.2 Clustering; applied in §4.2.4 and §4.3.1 (Fig. 4.12).
Unsupervised learning (无监督学习) has inputs x_n and no labels. The loss can no longer compare an output with a known answer, so each method defines its own target: keep the variance, keep the neighbours, or find the dense regions.
The data. A trajectory becomes a table with one row per frame and one column per feature. In my thesis (§4.2.4) the features were the distances between backbone beads, taken every five residues, of the TREM2 helix and each DAP12 helix. Each frame is then one point x_n in a space of D dimensions, where D is the number of distances. With large D the distances between points become nearly equal, and “conventional distance metrics lose their discriminative power” (§2.3.1). This is the curse of dimensionality (维数灾难), a term from Richard Bellman.
1901: principal component analysis (主成分分析, PCA). Karl Pearson invented it in 1901, and Harold Hotelling developed and named it independently in the 1930s. This is the “eigendecomposition of the covariance matrix” of §2.3.1:
C is the covariance matrix (协方差矩阵) of the features and is the mean frame. Its eigenvectors v_k are the principal components (主成分), and each eigenvalue λ_k is the variance of the data along v_k. Keeping the two components with the largest λ_k gives the 2D picture that retains the most variance. PCA can only rotate the axes and drop some of them. It is linear, which is the limit stated in §2.3.1.
1957–1967: k-means (k 均值聚类). Clustering (聚类) assigns points to groups. Stuart Lloyd proposed the standard algorithm at Bell Labs in 1957 (published 1982), and James MacQueen named it in 1967:
S_j is cluster j and μ_j is its centre. The number of clusters k must be chosen in advance, every point is assigned to a cluster, and the result favours round clusters of similar size. For MD frames this is a poor fit: frames in transit between two states are forced into one of them.
1996: density-based clustering. DBSCAN, by Martin Ester, Hans-Peter Kriegel, Jörg Sander and Xiaowei Xu, defines a cluster as a region where points are dense. It has two parameters, a radius ε and a minimum number of points, and it labels points in sparse regions as noise (噪声点). Its limit is the single radius: one density threshold for the whole data set.
2013: HDBSCAN. Campello, Moulavi and Sander removed the single threshold by examining all density levels at once. The Python library hdbscan (thesis ref. 184) followed in 2017. These two definitions are the “local density” and the “distance-weighted graph” of §2.3.2:
- The core distance is small where points are dense and large where they are sparse.
- The mutual reachability distance leaves dense points at their true separation and moves sparse points away from everything.
- The minimum spanning tree (最小生成树) joins all points using the smallest total d_mreach. Removing its edges from longest to shortest splits the data step by step, which gives the hierarchy of §2.3.2.
min_cluster_sizedecides which splits count. If a split leaves fewer points than this on one side, those points are dropped as noise and the cluster continues. The clusters that survive over the widest range of density are returned.cluster_selection_epsilon(thesis ref. 185) stops splitting below a chosen distance, so that a dense region is not cut into many small clusters.
2008 and 2018: t-SNE and UMAP. Laurens van der Maaten and Geoffrey Hinton published t-SNE in 2008. Leland McInnes, John Healy and James Melville published UMAP in 2018. Both are non-linear dimensionality reduction (降维): they place the points in 2D so that neighbours stay neighbours. These are the “weighted graph” and the embedding optimised by SGD in §2.3.1:
- First line: in the original space each frame i is linked to its nearest neighbours with a weight between 0 and 1. d_ij is the distance between frames i and j, ρ_i is the distance from i to its nearest neighbour, and s_i is a scale set separately for each frame. The two directed weights are combined into one symmetric weight w_ij.
- Second line: u_i is the 2D point that represents frame i, and q_ij is the matching weight in 2D. A and B are constants fixed by
min_dist. - Third line: the loss is a cross-entropy (交叉熵) between the two sets of weights. Its first term pulls neighbours together and its second pushes non-neighbours apart. SGD moves the points u_i until L stops falling.
Three consequences follow from the formulas.
n_neighborssets the scale. A small value shows local detail and many small islands; a large value shows broader structure.- The embedding keeps neighbour relations, not distances. The gap between two islands and the size of an island have no physical unit. §2.3.1 says this as “UMAP does not explicitly preserve global data density”. A
cluster_selection_epsilonapplied in UMAP space is therefore a number on the embedding’s scale, not in ångström. - The optimisation is stochastic. A different random seed gives a different layout, so
random_stateshould be fixed and recorded.
Why density suits MD. The MD note gave F(ξ) = −k_B T ln P(ξ): a region that is densely populated is a free-energy basin. A density-based cluster in a good feature space is therefore a candidate metastable state. The populations are equilibrium populations only if the sampling has converged.
Two meanings of “cluster”. In self-assembly, cluster analysis asks which molecules are in contact and how large each aggregate is. That is a connected-components calculation on a contact graph. It is a different method from the conformational clustering in this chapter.
1986–2012: deep learning
In my thesis: the “Deep learning” paragraph of §2.3: multilayered networks, neurons organised into layers, CNNs and autoencoders.
1969: the limit of one neuron. Marvin Minsky and Seymour Papert showed in their book Perceptrons that a single layer of perceptrons cannot learn the XOR function, because one neuron can only separate two classes with a straight line. Several layers can do it, but nobody had an efficient way to train the layers in the middle. Interest in neural networks fell for more than a decade.
A network of layers (神经网络). This is “neurons, which are organised into layers” in §2.3:
Each layer is the 1958 neuron applied many times in parallel. is the output of layer l, is its table of weights and its biases. The layers between input and output are the hidden layers (隐藏层). Without the activation function σ, any stack of layers would reduce to one linear model, so the non-linearity is what makes depth useful. “Deep” (深度学习) means many layers.
1986: backpropagation (反向传播). David Rumelhart, Geoffrey Hinton and Ronald Williams showed in Nature that hidden layers can be trained by applying the chain rule (链式法则) backwards from the loss. The mathematical method, reverse-mode automatic differentiation (自动微分), had been published by Seppo Linnainmaa in 1970:
One forward pass computes the output, and one backward pass gives the gradient of the loss with respect to every weight, at about the cost of the forward pass. Gradient descent then works for models with millions of parameters. The same operation later gives ML potentials their forces: F = −∂E/∂r is a gradient of one number with respect to many inputs.
1988–1989: what a network can represent. George Cybenko, and Kurt Hornik with co-workers, proved that a network with one hidden layer can approximate any continuous function if the layer is wide enough. The theorem says a good set of weights exists. It does not say that training will find it, or that the result will hold outside the training data.
1980–1998: convolutional networks (卷积神经网络, CNN). Kunihiko Fukushima’s neocognitron (1980) introduced the layer type. Yann LeCun’s group trained such networks by backpropagation in 1989 to read handwritten postcodes, and published LeNet-5 in 1998:
A small filter k is slid along the input, and the same weights are used at every position. The network then needs far fewer parameters, and a pattern is recognised wherever it occurs. This is the first case of building a symmetry of the problem into the model. For images the symmetry is translation. For atoms it will be rotation (chapter “2007–2022”).
Autoencoders (自编码器). An autoencoder is a network trained to reproduce its own input through a narrow middle layer. The middle layer is then a learned low-dimensional description of the data. With linear layers it gives the same subspace as PCA; Mark Kramer described the non-linear version in 1991 as “nonlinear PCA”. It is unsupervised, which is why §2.3 lists it under representation learning.
Classification: softmax and cross-entropy.
The network gives one score z_c per class, and softmax turns the scores into probabilities p_c that sum to 1. The loss is the negative log-probability of the correct class c_n: the cross-entropy that UMAP also uses. Softmax is the Boltzmann distribution of the MD note with z_c = −E_c / k_B T. The name is from John Bridle (1989).
Overfitting (过拟合). A network with more parameters than data points can reproduce the training data exactly, including its noise, and still fail on new data. Two standard counter-measures:
- Regularisation (正则化): the extra term penalises large weights. γ sets its strength.
- Dropout (Hinton and co-workers, 2012): during training a random part of the neurons is switched off at each step, so the network cannot rely on any single one.
Neither replaces a test on data the model has never seen (chapter “What ML cannot see”).
2009–2012: data and GPUs. Fei-Fei Li’s group presented ImageNet in 2009; it grew to more than 14 million labelled images. In 2012 AlexNet, a CNN by Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton, was trained on two GPUs and won the ImageNet challenge with a top-5 error of 15.3%, more than 10.8 percentage points ahead of the runner-up. The ideas were from 1986–1998. What changed was the amount of labelled data and the hardware.
2014–2020: attention, transformers and diffusion models
In my thesis: “transformer models, which have revolutionised natural language processing tasks” (§2.3). Both ideas in this chapter are the machinery inside AlphaFold (§2.3.3).
The problem: long-range relations. A sentence and a protein sequence share one difficulty. Two positions far apart in the sequence can depend strongly on each other: two residues 100 positions apart may be in contact in the folded structure. A CNN sees only a short window, and earlier sequence models passed information along one step at a time and lost it over long distances.
2014 and 2017: attention (注意力机制). Dzmitry Bahdanau, Kyunghyun Cho and Yoshua Bengio introduced attention for machine translation in 2014. In 2017 Ashish Vaswani and co-authors published “Attention Is All You Need”, a network built from attention alone: the transformer. This is the core of the “transformer models” of §2.3:
- The input is a sequence of tokens (词元): words in a sentence, residues in a protein.
- Each token i sends out a query vector (a row of Q). Each token j offers a key vector (a row of K) and a value vector (a row of V).
- The dot product of query i with key j measures how relevant token j is to token i. Softmax turns these scores into weights that sum to 1.
- The output for token i is the weighted average of all value vectors.
- d_k is the length of the key vectors. Dividing by keeps the scores in a range where softmax does not saturate.
Every token can take information from every other token in one step, however far apart they are, and the weights are learned from data. The cost is one weight per pair of tokens, so memory grows with the square of the sequence length. This is why structure predictors run out of GPU memory on long sequences.
For proteins, an attention weight between residues i and j is a learned, soft statement that the two residues matter to each other. Its role is close to that of an entry in a contact map computed from MD, with one difference: it is learned from data and has no distance cut-off.
2018: language models and self-supervised learning (自监督学习). BERT and the first GPT model were transformers trained on plain text: BERT by hiding words and predicting them, GPT by predicting the next word. The labels come from the data itself, so no human labelling is needed. This differs from the semi-supervised learning (半监督学习) of §2.3, which mixes a few labelled examples with many unlabelled ones. The same training applied to millions of protein sequences gives protein language models (蛋白质语言模型). Their internal vectors for each residue can be used as input features for a small supervised model.
2015 and 2020: diffusion models (扩散模型). A generative model (生成模型) learns the distribution of the data and produces new samples from it. Jascha Sohl-Dickstein and co-authors introduced diffusion models in 2015, using ideas from non-equilibrium thermodynamics. Jonathan Ho, Ajay Jain and Pieter Abbeel gave the form now in use (DDPM) in 2020:
- x_0 is a real data point, for example the coordinates of all atoms in a structure. x_t is the same point after t steps of added Gaussian noise ε.
- falls from 1 at t = 0 to nearly 0 at the last step, where x_t is pure noise.
- The network ε_θ is trained to predict the noise that was added. The loss is a squared error, as in 1805.
- To generate, start from pure noise and remove the predicted noise step by step.
The forward process is a random walk of the data point, the same mathematics as Brownian motion. The reverse process is a stochastic dynamics driven by a learned force. For a Boltzmann distribution , the gradient of ln P is −∇U / k_B T, the physical force in units of k_B T. The quantity a diffusion model learns is this gradient for the distribution of its training data.
Two practical consequences:
- Each run returns a different sample. Results depend on the random seed and on the number of samples drawn.
- The samples follow the distribution of the training data (for structure predictors, experimental structures). They are not a Boltzmann ensemble at 310 K.
2007–2022: ML meets atoms
In my thesis: not covered. This chapter attaches to Fig. 2.1 in §2.1 (the gap between AIMD and all-atom MD), to the sentence there that machine learning is beginning to make AIMD-level accuracy feasible for larger systems, and to the force field of Eqs. 2.9 and 2.11, which it replaces.
The problem. DFT gives accurate energies and forces, but its cost grows roughly with the cube of the number of electrons. A force field is fast, but its form is fixed: fixed partial charges, harmonic bonds that cannot break. A machine-learned interatomic potential (机器学习势, MLIP) is a regression model between the two. Its input is the positions and elements of the atoms, its label is the DFT energy, and once trained it is used in MD in place of the force field.
2007: Behler and Parrinello. Neural networks had been fitted to potential-energy surfaces of small systems since the 1990s. Jörg Behler and Michele Parrinello made the approach work for systems of any size:
- The total energy is a sum of atomic energies E_i. Each E_i comes from a neural network.
- G_i is a descriptor (描述符): a list of numbers that describes the neighbours of atom i inside a cut-off radius r_c.
- The force is thesis Eq. 2.6 applied to the network, computed by backpropagation.
- Because the energy is a sum over atoms, a model trained on small systems can be run on larger ones.
- The cut-off is the same idea as r_c in the non-bonded settings of an MD run, with the same weakness: the model sees nothing beyond it, including long-range electrostatics.
Symmetry (对称性). The energy of a molecule does not change when the molecule is moved or rotated, or when two identical atoms are swapped, and the forces rotate with the molecule. For any rotation R:
The first property is invariance (不变性) and the second is equivariance (等变性). A model that does not have them built in must learn them from many rotated copies of the same data. Behler and Parrinello built invariance into the descriptor, using functions of distances and angles only. In 2010 Albert Bartók, Mike Payne, Risi Kondor and Gábor Csányi combined local descriptors with Gaussian process regression (the Gaussian approximation potential, GAP).
2017: message passing on a graph (消息传递). A molecule is treated as a graph (图): atoms are the nodes (节点), and each pair of atoms closer than r_c is joined by an edge (边). Graph neural networks (图神经网络) date from 2009. Justin Gilmer and co-authors applied them to quantum chemistry in 2017 under the name message passing:
- Each atom i carries a feature vector h_i, which starts as a code for its element.
- In each layer, atom i collects a message m_i from its neighbours N(i) and updates h_i. ψ and φ are small neural networks.
- After several layers, h_i describes the chemical environment of atom i. The atomic energy E_i is read from the final h_i.
The descriptor is now learned, not designed by hand. The same network can be trained to predict a property of each atom (a partial charge, a Fukui function) or of the whole molecule, in place of the energy.
2021–2022: equivariant networks (等变神经网络). NequIP (Simon Batzner and co-authors, 2021) and MACE (Ilyes Batatia and co-authors, 2022) carry vectors and higher tensors in h_i that rotate with the molecule. They reach a given accuracy with far less training data. Since about 2023, potentials of this type have been trained on millions of DFT calculations covering much of the periodic table and released as general-purpose (“foundation”) models. Fine-tuning (微调) means continuing the training of such a model on a small set of your own DFT data.
What an ML potential inherits.
- Its accuracy cannot exceed that of its labels. The functional, basis set and dispersion correction of the DFT note set the ceiling.
- It is reliable only for configurations that resemble its training data. A model trained on molecules near equilibrium has not seen bonds breaking.
- It is slower than a force field by roughly two to three orders of magnitude per step, and far faster than DFT. These are order-of-magnitude figures; they depend on the model and the hardware.
ML/MM. By analogy with QM/MM (Fig. 2.1 of my thesis), an ML potential can describe a small reactive region while the force field describes the rest.
2018–2024: ML meets proteins
In my thesis: §2.3.3 AlphaFold structure prediction; used in Chapter 3 (the AF_TD model) and in §4.2.1 (seven TREM2 variants, Figs. 4.1–4.7).
The problem and the test. Predicting the 3D structure of a protein from its sequence (结构预测) has had a blind test since 1994: CASP, held every two years, in which groups predict structures that have been solved but not yet released. Neural networks had been used for secondary structure since the 1980s; PSIPRED (thesis ref. 174) is of this kind.
2011: co-evolution (共进化). Two residues that touch in the folded protein tend to mutate together during evolution. In a multiple sequence alignment (多序列比对, MSA) of many related sequences, pairs of columns that vary together therefore point to contacts. In 2011 this signal was shown to be enough to predict a protein’s fold. It is the main input of AlphaFold, and thesis ref. 177 uses the same signal to predict mutation effects.
2018 and 2020: AlphaFold. AlphaFold 1 from DeepMind placed first at CASP13 in 2018. AlphaFold 2 won CASP14 in 2020 with a median score of 92.4 on the 100-point GDT scale, close to experimental accuracy for many targets. The paper and the code appeared in July 2021. AlphaFold 2 is a supervised model: the input is the sequence with its MSA, the label is the experimental structure from the PDB, and the network uses attention between the sequences of the MSA and between pairs of residues.
2022: ColabFold. Milot Mirdita and co-authors combined AlphaFold 2 with a much faster sequence search (MMseqs2) and made it run in a notebook. This is the tool I used, at version 1.5.2.
Reading the output. Figs. 4.1–4.7 of my thesis show three panels for each TREM2 mutant. Each corresponds to one idea.
pLDDT (panel B). This is the “residue-level confidence metric” of §2.3.3:
LDDT compares a predicted structure with the true one. For each residue it takes the distances to atoms within 15 Å and counts how many are reproduced within four tolerances. It needs no superposition, so it measures local accuracy only. pLDDT is the network’s own prediction of this score, from 0 to 100, made without knowing the true structure. Above 90 is very high confidence, 70–90 is confident, and below 50 often indicates disorder, as §2.3.3 says.
PAE (panel A). The predicted aligned error (预测对齐误差) is a table with one entry for each pair of residues. Entry (i, j) is the expected position error of residue j, in ångström, when the predicted and true structures are superposed on residue i. Low PAE between two helices or two chains means their relative placement is predicted with confidence. For a complex, this is the quantity to read. pLDDT says nothing about how two chains sit relative to each other.
MSA coverage (panel C). This is the number of aligned sequences at each position. Where the alignment is shallow, the co-evolution signal is weak and confidence falls.
Five models (rank_1 to rank_5). AlphaFold 2 has five separately trained sets of parameters. ColabFold runs all five and ranks the results by confidence.
A consequence for point mutants. A point mutant has almost the same MSA as the wild type. AlphaFold 2 therefore tends to return almost the same structure for both, with almost the same confidence. Similar predictions for K186A and the wild type are not evidence that the mutation leaves the structure unchanged. My thesis does not rely on such evidence: the AlphaFold models were “initial conformational hypotheses for docking”, and the effect of each mutation was assessed by coarse-grained self-assembly and all-atom MD (§4.2.1).
What the model does not contain. §2.3.3 already lists it: one static structure, no membrane, no dynamics, and low confidence that often reflects flexibility and not error.
2021–2024: complexes and ligands. AlphaFold-Multimer (October 2021) was trained on protein complexes. AlphaFold 3 (May 2024) predicts proteins together with nucleic acids, ligands and ions, and generates the atom coordinates with a diffusion model. Predicting a protein and its ligand together is called co-folding (共折叠). Open-source models of the same type have followed. For ligands, these models are most reliable when similar ligands and pockets are in their training data, and they can return poses with wrong stereochemistry or atomic clashes.
2024: two Nobel Prizes. The Chemistry prize went half to David Baker for computational protein design and half to Demis Hassabis and John Jumper for AlphaFold. The Physics prize went to John Hopfield and Geoffrey Hinton for foundational work on neural networks. Hopfield’s 1982 network has an energy function of the Ising type from statistical physics, and Hinton’s Boltzmann machine samples its states from the Boltzmann distribution.
What ML cannot see, and how to test a model honestly
In my thesis: the closing sentences of §2.3.2 (hyperparameters are tuned and clusters “validated against physical criteria”), the caveat on semi-supervised learning in §2.3, and §2.3.3 (models as “structurally informed hypotheses”).
A fitted function knows only its training data. Every limit in this chapter follows from that sentence.
Training, validation and test sets (训练集、验证集、测试集):
is the loss for one example. The parameters θ are fitted on the training set. The hyperparameters (超参数), which are the settings chosen by the user such as the learning rate, the number of layers, n_neighbors or min_cluster_size, are chosen on a separate validation set. The test set is used once, at the end. L_test estimates how the model performs on new data, which is called generalisation (泛化). A large gap between L_test and L_train is the measurable sign of overfitting. With little data, cross-validation (交叉验证) rotates the roles: the data are cut into k parts and each part serves once as the test set.
Data leakage (数据泄漏). The test is valid only if the test set is independent of the training set. Three cases matter in molecular modelling.
- MD frames. Consecutive frames of one trajectory are nearly identical. If frames are split at random, the test set contains near-copies of training frames and the test error is far too optimistic. Split by trajectory or replica, or by long time blocks.
- Proteins. Homologous sequences have similar structures. Split by sequence similarity, or by date: a structure predictor is tested on structures released after its training cut-off.
- Molecules. Split by chemical family, so that the test molecules are not close analogues of training molecules.
The number of independent samples in a trajectory is much smaller than the number of frames:
T_sim is the length of the trajectory and τ is the correlation time of the quantity of interest. If a ligand binds and unbinds only a few times in 1 µs, N_eff for binding is a few, however many frames were saved.
Interpolation and extrapolation (内插与外推). A model is reliable between its training points and unreliable beyond them, and it gives no warning of its own. The CGenFF penalty score is a hand-made warning of this kind for a force field. For ML potentials a common warning is the disagreement between several models trained on the same data.
Confidence is not accuracy. pLDDT and PAE are themselves outputs of a trained network. They are calibrated on proteins like those in the PDB. For inputs far from that set, a prediction can be confident and wrong.
Unsupervised methods have no test set. There are no labels, so there is no L_test. Three checks stand in for it:
- Stability to settings: do the same clusters appear over a range of
n_neighborsandmin_cluster_size, and with a different random seed? - Stability to data: do they appear when only half of the trajectory, or only some of the replicas, is used?
- Physical validation: do the clusters differ in an observable that was not used to define them?
My thesis applies the third check: the clusters are characterised by contact maps and representative structures (Figs. 4.13–4.19). Looking back, two things could be stronger. Contact maps are closely related to the distance features that defined the clusters, so the check is only partly independent; the all-atom simulations started from each cluster are the better test. And the hyperparameters were chosen “iteratively to yield physically meaningful conformational clusters”, which leaves the number of clusters partly a choice. What I would add today is a scan showing how the number of clusters changes over a grid of settings.
Baselines (基线). A model’s error means little alone. It has to be compared with the simplest method that could work: the mean of the training labels, a linear fit on one physical descriptor, or the nearest training example.
| Claim | Test that supports it | Common failure |
|---|---|---|
| These clusters are real conformational states | same clusters with other settings, seeds and subsets; an independent observable separates them | clusters produced by the embedding or by tuning |
| The model predicts a property for new molecules | test molecules from chemical families absent from training | random split of close analogues |
| A model trained on MD frames generalises | split by trajectory or replica | random split of frames |
| The predictor distinguishes two mutants | difference larger than the spread over seeds and models; known positive and negative controls | comparing single predictions |
| The ML potential is accurate for my system | energies and forces against DFT on frames from my own MD; a stable long run | validated on a public benchmark only |
| The predicted complex is correct | an experimental structure; failing that, agreement of independent methods plus physical checks | a high confidence score taken as proof |
How the three notes fit together. DFT gives accurate energies for small systems, which serve as labels. MD gives sampling, which serves as data. ML fits functions to either. It can analyse MD (as in my thesis), replace the force field (ML potentials) or propose starting structures (AlphaFold), and in each role it is tested against the physics and not the other way round.
Where the ideas meet my work
Each row is a tool or setting from my thesis or my current work, traced to the idea behind it.
| Tool or setting | In my thesis and papers | In current work | Idea, and where it starts |
|---|---|---|---|
| One feature vector per frame | bead–bead distances, §4.2.4 | distance and contact features for PHA systems | a trajectory as a data table; “1901–2018” |
| PCA | described as the linear method, §2.3.1 | a first look at any feature table | eigenvectors of the covariance matrix; 1901 |
UMAP, n_neighbors 50 and 10 |
§2.3.1, §4.2.4, Fig. 4.12 | PHA simulations | neighbour graph, cross-entropy, SGD; 2018 |
HDBSCAN, min_cluster_size 50, selection epsilon 2.0 and 1.5 |
§2.3.2, §4.2.4, Fig. 4.12 | PHA simulations | mutual reachability distance, minimum spanning tree; 2013 |
| Stochastic gradient descent | inside UMAP, §2.3.1 | training of any model | 1847 and 1951 |
| Steepest-descent minimisation | start of every run, §4.2.3 | start of every run | gradient descent on U; 1847 |
| Force-field parameters | CHARMM36m, §2.2.2 | GAFF2 and CGenFF for PHA | least-squares fitting and extrapolation; 1805 |
| ColabFold v1.5.2 (AlphaFold 2) | Chapter 3 (AF_TD); §4.2.1 | – | supervised training on the PDB, attention; 2020–2022 |
| pLDDT, PAE, MSA coverage | §2.3.3, Figs. 4.1–4.7 | – | a learned confidence; “2018–2024” |
| AlphaFold 3 | a reference for complex assembly, §4.2.1 | – | diffusion model; 2015–2024 |
| Structure–property regression | not used | PHA datasets: structure in, MD property out (in progress) | least squares and honest splits; 1805 |
| DFT results as labels | not used | reference data for an ML potential (in progress) | supervised regression; 2007 |
| ML potential | one sentence in §2.1 | DFT-to-ML-potential workflow with active learning (in progress) | Behler–Parrinello, message passing; 2007–2022 |
| Independent replicas | three per all-atom system | data split by trajectory, not by frame | independent samples; “What ML cannot see” |
Symbol key
§2.3 of my thesis has no equations, so every symbol here is new except r_i, F_i and r_c, which keep their meaning from Chapter 2 of the thesis. Some letters carry two meanings: k is the number of clusters in k-means, the index of an eigenvector, and the filter in a convolution; h is the output of a layer and the feature vector of an atom; σ is the activation function here and the Lennard-Jones distance σ_ij in the MD note.
| Symbol | Meaning | Chapter | 中文 |
|---|---|---|---|
| x_n, y_n, | input (feature vector) of example n; its label; the model’s output | 1805–1958 | 输入(特征向量);标签;预测值 |
| N, D | number of examples (frames); number of features | 1805–1958 | 样本数;特征数(维数) |
| θ; w, b | all parameters of a model; weights and bias | 1805–1958 | 参数;权重、偏置 |
| L; | loss over a data set; loss for one example | 1805–1958 | 损失函数 |
| η | learning rate | 1805–1958 | 学习率 |
| σ(·) | activation function | 1805–1958 | 激活函数 |
| C, | covariance matrix of the features; mean of the data | 1901–2018 | 协方差矩阵;均值 |
| v_k, λ_k | eigenvector k of C (a principal component); its eigenvalue | 1901–2018 | 特征向量(本征向量);特征值(本征值) |
| S_j, μ_j, k | cluster j; its centre; number of clusters | 1901–2018 | 簇;簇中心;簇数 |
| core_m(a) | distance from point a to its m-th nearest neighbour | 1901–2018 | 核心距离 |
| d(a,b), d_mreach(a,b) | distance between two points; mutual reachability distance | 1901–2018 | 距离;相互可达距离 |
| d_ij, ρ_i, s_i | UMAP: distance between frames i and j; distance from i to its nearest neighbour; local scale of frame i | 1901–2018 | 距离;最近邻距离;局部尺度 |
| w_ij, q_ij | UMAP: neighbour weight in the original space; in the 2D embedding | 1901–2018 | 边权重 |
| u_i; A, B | 2D point that represents frame i; constants set by min_dist |
1901–2018 | 嵌入坐标 |
| , , | output, weights and biases of layer l | 1986–2012 | 第 l 层的输出、权重、偏置 |
| L_layers | number of layers | 1986–2012 | 层数 |
| z_c, p_c | score and probability of class c | 1986–2012 | 得分;概率 |
| γ | strength of the regularisation term | 1986–2012 | 正则化系数 |
| Q, K, V; d_k | queries, keys and values; length of a key vector | 2014–2020 | 查询、键、值 |
| x_0, x_t | a data point; the same point after t noise steps | 2014–2020 | 原始数据;加噪后的数据 |
| ε, ε_θ, | added noise; the network’s prediction of it; fraction of the signal left at step t | 2014–2020 | 噪声;预测噪声 |
| E, E_i, G_i | total energy; energy assigned to atom i; descriptor of its neighbourhood | 2007–2022 | 总能量;原子能量;描述符 |
| r_i, F_i, r_c | position of atom i; force on it (thesis Eq. 2.6); cut-off radius | 2007–2022 | 位置;力;截断半径 |
| R | a rotation | 2007–2022 | 旋转 |
| h_i, m_i, N(i) | feature vector of atom i; message it receives; its neighbours | 2007–2022 | 节点特征;消息;近邻 |
| ψ, φ | message function; update function | 2007–2022 | 消息函数;更新函数 |
| LDDT, pLDDT | local distance difference test; its predicted value, 0–100 | 2018–2024 | 局部距离差异测试;预测值 |
| PAE(i, j) | predicted aligned error of residue j when aligned on residue i | 2018–2024 | 预测对齐误差 |
| L_train, L_test | loss on the training set; on the test set | What ML cannot see | 训练误差;测试误差 |
| τ, T_sim, N_eff | correlation time; trajectory length; number of independent samples | What ML cannot see | 相关时间;模拟时长;有效样本数 |
Glossary: English–中文
Variants are in brackets. The third column gives where the term appears in my thesis; a dash means it does not. One clash to know: 特征向量 is used both for “feature vector” and for “eigenvector”. Physics and quantum chemistry texts avoid it by writing 本征向量 and 本征值 for the eigen terms.
Learning and models
| English | 中文 | Thesis |
|---|---|---|
| Machine learning | 机器学习 | §2.3 |
| Supervised learning | 监督学习(有监督学习) | §2.3 |
| Unsupervised learning | 无监督学习(非监督学习) | §2.3 |
| Semi-supervised learning | 半监督学习 | §2.3 |
| Self-supervised learning | 自监督学习 | – |
| Deep learning | 深度学习 | §2.3 |
| Neural network; neuron | 神经网络;神经元 | §2.3 |
| Layer; hidden layer | 层;隐藏层(隐含层) | §2.3 |
| Feature; label | 特征;标签 | §2.3 (labelled data) |
| Parameter; weight; bias | 参数;权重;偏置 | – |
| Hyperparameter | 超参数 | §2.3.2 |
| Training | 训练 | §2.3 |
| Regression; classification | 回归;分类 | §2.3.1 (classification) |
| Loss function | 损失函数 | – |
| Mean squared error | 均方误差 | – |
| Least squares | 最小二乘法 | – |
| Gradient descent | 梯度下降法 | – |
| Stochastic gradient descent | 随机梯度下降 | §2.3.1 |
| Learning rate | 学习率 | – |
| Perceptron | 感知机(感知器) | – |
| Activation function | 激活函数 | – |
| Backpropagation | 反向传播 | – |
| Chain rule; automatic differentiation | 链式法则;自动微分 | – |
| Convolutional neural network; filter | 卷积神经网络;卷积核 | §2.3 |
| Autoencoder | 自编码器(自动编码器) | §2.3 |
| Softmax | usually left as softmax(归一化指数函数) | – |
| Cross-entropy | 交叉熵 | – |
| Attention | 注意力机制 | – |
| Transformer | usually left as Transformer | §2.3 |
| Token | 词元(标记) | – |
| Language model; protein language model | 语言模型;蛋白质语言模型 | – |
| Generative model; diffusion model | 生成模型;扩散模型 | – |
| Random seed | 随机种子 | – |
Structure without labels
| English | 中文 | Thesis |
|---|---|---|
| Dimensionality reduction | 降维 | §2.3.1 |
| Curse of dimensionality | 维数灾难(维度灾难) | §2.3.1 (described) |
| Principal component analysis | 主成分分析 | §2.3.1 |
| Covariance matrix | 协方差矩阵 | §2.3.1 |
| Eigenvalue; eigenvector | 特征值(本征值);特征向量(本征向量) | §2.3.1 (eigendecomposition) |
| Manifold | 流形 | §2.3.1 |
| Embedding | 嵌入 | §2.3.1 |
| Clustering; cluster | 聚类;簇 | §2.3.2 |
| k-means | k 均值聚类 | – |
| Density-based clustering | 基于密度的聚类 | §2.3.2 |
| Core distance | 核心距离 | – |
| Mutual reachability distance | 相互可达距离(互达距离) | – |
| Minimum spanning tree | 最小生成树 | §2.3.2 |
| Noise point | 噪声点 | §2.3.2 |
Atoms and proteins
| English | 中文 | Thesis |
|---|---|---|
| Machine-learned interatomic potential | 机器学习势(机器学习原子间势、机器学习力场) | – |
| Descriptor | 描述符 | – |
| Symmetry; invariance; equivariance | 对称性;不变性;等变性 | – |
| Gaussian process regression | 高斯过程回归 | – |
| Graph neural network | 图神经网络 | – |
| Message passing; node; edge | 消息传递;节点;边 | – |
| Foundation model; fine-tuning | 基础模型;微调 | – |
| Structure prediction | 结构预测 | §2.3.3 |
| Multiple sequence alignment | 多序列比对 | Figs. 4.1–4.7 |
| Co-evolution | 共进化(协同进化) | §2.3 (co-variation) |
| Confidence | 置信度 | §2.3.3 |
| Predicted aligned error | 预测对齐误差(预测比对误差) | Figs. 4.1–4.7 |
| Co-folding | 共折叠 | – |
Testing a model
| English | 中文 | Thesis |
|---|---|---|
| Training, validation and test set | 训练集、验证集、测试集 | – |
| Cross-validation | 交叉验证 | – |
| Generalisation | 泛化 | – |
| Overfitting | 过拟合 | – |
| Regularisation | 正则化 | – |
| Dropout | usually left as Dropout(随机失活) | – |
| Data leakage | 数据泄漏(数据泄露) | – |
| Interpolation; extrapolation | 内插(插值);外推 | – |
| Baseline; benchmark | 基线;基准(基准测试) | – |
Sources and further reading
My thesis and papers.
- Z. Zhong, Atomistic Insights into Membrane Protein Complexes and Simulation-Guided Evaluation of Peptide-Membrane Interactions, PhD thesis, King’s College London, 2026. Chapter 2 (Methods) is posted with these notes; §2.3 is the starting point of this one.
- Z. Zhong, M. B. Ulmschneider and C. D. Lorenz, J. Chem. Inf. Model. (2025), https://doi.org/10.1021/acs.jcim.5c01891. The UMAP–HDBSCAN analysis and the ColabFold models of the TREM2 mutants. Code: CodeForMutationTREM2.
- Z. Zhong, M. B. Ulmschneider and C. D. Lorenz, ACS Omega (2024), https://doi.org/10.1021/acsomega.4c03060. The TREM2–DAP12 complex, including the AlphaFold-based model. Code: CodeForTREM2-DAP12.
Reviews I started from (all cited in my thesis).
- J. G. Greener, S. M. Kandathil, L. Moffat and D. T. Jones, “A guide to machine learning for biologists”, Nat. Rev. Mol. Cell Biol. 23, 40–55 (2022).
- A. Glielmo, B. E. Husic, A. Rodriguez, C. Clementi, F. Noé and A. Laio, “Unsupervised learning methods for molecular simulation data”, Chem. Rev. 121, 9722–9758 (2021).
- F. Trozzi, X. Wang and P. Tao, “UMAP as a dimensionality reduction tool for molecular dynamics simulations of biomacromolecules”, J. Phys. Chem. B 125, 5022–5034 (2021).
Papers behind the formulas.
- Least squares: A.-M. Legendre (1805); C. F. Gauss (1809). Gradient descent: A.-L. Cauchy (1847). Stochastic approximation: H. Robbins and S. Monro, Ann. Math. Stat. (1951).
- Perceptron: F. Rosenblatt, Psychol. Rev. (1958). Backpropagation: D. E. Rumelhart, G. E. Hinton and R. J. Williams, Nature 323, 533–536 (1986).
- PCA: K. Pearson, Philos. Mag. (1901). k-means: J. MacQueen (1967); S. Lloyd, IEEE Trans. Inf. Theory (1982). DBSCAN: M. Ester, H.-P. Kriegel, J. Sander and X. Xu, KDD (1996).
- HDBSCAN: R. J. G. B. Campello, D. Moulavi and J. Sander, PAKDD (2013); L. McInnes, J. Healy and S. Astels, J. Open Source Softw. 2, 205 (2017); C. Malzer and M. Baum (2020) for
cluster_selection_epsilon. - t-SNE: L. van der Maaten and G. Hinton, J. Mach. Learn. Res. (2008). UMAP: L. McInnes, J. Healy and J. Melville, arXiv:1802.03426 (2018).
- Convolutional networks: Y. LeCun et al., Neural Comput. (1989); Y. LeCun, L. Bottou, Y. Bengio and P. Haffner, Proc. IEEE (1998). AlexNet: A. Krizhevsky, I. Sutskever and G. E. Hinton, NeurIPS (2012).
- Attention: D. Bahdanau, K. Cho and Y. Bengio, arXiv:1409.0473 (2014); A. Vaswani et al., “Attention is all you need”, NeurIPS (2017).
- Diffusion models: J. Sohl-Dickstein et al., ICML (2015); J. Ho, A. Jain and P. Abbeel, NeurIPS (2020).
- ML potentials: J. Behler and M. Parrinello, Phys. Rev. Lett. (2007); A. P. Bartók, M. C. Payne, R. Kondor and G. Csányi, Phys. Rev. Lett. (2010). Message passing: J. Gilmer et al., ICML (2017). Equivariant potentials: S. Batzner et al., NequIP (2021); I. Batatia et al., MACE (2022).
- AlphaFold: J. Jumper et al., Nature 596, 583–589 (2021). ColabFold: M. Mirdita et al., Nat. Methods 19, 679–682 (2022). AlphaFold 3: J. Abramson et al., Nature 630, 493–500 (2024). lDDT: V. Mariani, M. Biasini, A. Barbato and T. Schwede, Bioinformatics (2013).
- AlphaFold 2 and point mutations: G. R. Buel and K. J. Walters, Nat. Struct. Mol. Biol. (2022); M. A. Pak et al., PLoS ONE (2023).
Names and dates were checked in November 2026 against the English Wikipedia articles on each topic: Least squares, Gradient descent, Stochastic gradient descent, Perceptron, Machine learning, Backpropagation, Universal approximation theorem, Convolutional neural network, AlexNet, ImageNet, Autoencoder, Dilution (dropout), Softmax function, Principal component analysis, Curse of dimensionality, k-means clustering, DBSCAN, t-SNE, Nonlinear dimensionality reduction, Transformer, Diffusion model, Machine-learned interatomic potential, Graph neural network, AlphaFold, CASP, Protein structure prediction, David Baker, Hopfield network, Boltzmann machine.
Companion notes. MD from the beginning and DFT from the beginning.
About this note. Drafted with the help of an AI assistant (Claude).
Comments
No comments yet.