Updates to fitting and optimization (November 2026)

Back to the documentation index. Added November 2026. Group-level results only.

Every setting below, from the number of epochs to the order in which parameters are learned, is tuned to the dataset, the way a learning rate or a penalty is. This page records how we tune them on UK Biobank and how to tune them on new data. It has three parts. The first applies directly to the model documented on this site. The second and third describe the successor model, which is documented on the Mendelnoulli site.

  1. When to stop training: in a plateau of about 300 to 400 epochs, chosen on held-out people. Not when the training loss flattens.
  2. What was added to the model: a health component, per-person frailty, and polygenic scores with ancestry removed (the "triplet").
  3. How fitting changed: a staged fit. The health component is established first, then the sex effects are learned.

1. When to stop training: a plateau of about 300 to 400 epochs, chosen on held-out people

The manuscript recipe trains each batch for 300 epochs, inside the held-out plateau shown below. That is an early stop by design. It is not convergence of the training loss, and the training loss should not be used to decide when to stop.

Why the training loss cannot tell you when to stop

The non-centered model writes each person's loading as a genetic part plus a person-specific part, λ = reference + G·γ + δ. The likelihood sees only λ. The person-specific term δ has about ten million free entries per 10,000-person batch and a weak prior, so it keeps fitting the training batch for as long as training runs. The training loss therefore falls at 300 epochs, at 2,000, and beyond. That says δ is fitting the batch more closely. It says nothing about whether γ has improved or whether the model predicts better.

What happens on held-out people as training continues

What we measured: the backbone trained on one batch of 10,000 people and frozen at each epoch, the person terms refitted on a disjoint batch, and scores taken on the years after enrolment.

epochstraining lossheld-out NLLobserved / expected10-year AUC (median, 28 groups)
5061.6.009422.83.659
15054.5.008721.43.676
30048.8.008691.11.679
60040.6.008780.80.672
200036.0.009790.43.660

What to do when you train this model

  1. Use the stated number of epochs for the stated recipe. Do not train until the loss stops falling.
  2. If you change the model, the dataset or its size, the learning rate or the schedule, re-derive the stop: save checkpoints across a range of epochs, score each on held-out people, and stop where calibration is closest to 1 with held-out NLL still on its floor.
  3. Report γ as the mean over batches, with the epoch stated. Its size changes along the training path, and one batch is noisy.
  4. The centered and non-centered forms share an objective and its stationary points. They take different paths, and neither is run to that point here.

Which model these numbers come from

The table above was measured on the successor model described next. The model on this site shares the parameterisation and the same recovery simulation, and its learning-rate, schedule and prior-weight sweeps selected the same 300-epoch constant-rate recipe on held-out AUC. The full held-out curve was measured on the successor model. Details: training length and stability.


2. What was added to the model: a health component, per-person frailty, and ancestry-removed scores

In the original model a person's signature weights have to carry two things at once: signature composition, meaning which diseases they have, and rate, meaning how much disease they have. These are different things, and mixing them distorts both the signatures and the genetic effects. The three additions below separate them. Together we call them the "triplet." All models are wrong, but some are less wrong, as I imagine will be the case as noulli evolves!

A health component: somewhere for healthy years to go

Next to the K disease signatures, each person also gets a "healthy" component. It's anchored to the population's disease-free curve: the log-odds of staying free of disease at each age. We temper that curve toward the average of the disease signatures (factor 0.6) and shift it to a mean of 1.5. The result is a healthy reference that is strongest when people are young, fades with age, and stays above the most heavily loaded disease signature through mid-life. Someone who stays healthy can load on this component rather than being pushed into whichever disease signature fits least badly.

It also fixes an identifiability problem. Signature weights are a softmax, so adding the same shift to every component changes nothing. We estimate the genetic level of the health component once and then hold it fixed, which makes the genetic effects on the other components absolute rather than relative. The health component also has no genetic age trend, so the age interactions are measured against it.

Per-person frailty: how much disease, kept separate from which diseases

Because θi is a composition (that inherently sums to 1), two people with the same mix of diagnoses get the same θi even if one has twice as many diagnoses. So each person gets one frailty, fi, applied after the sum over components:

1 − π̃ = (1 − π)exp(fi)

Here exp(fi) multiplies that person's cumulative hazard for every disease at every age. It changes their overall disease rate but not their signature composition. The values are centered, and their prior has SD 0.5.

The frailty is what makes the health component work. A single healthy curve can't fit both sexes, whose overall rates differ, and without frailty it ends up calibrated for women. In our ablation, men's weight on the health component went from 0.14 to 0.56 once frailty was added. It's pretty cool because if you add more data suggesting someone is more or less healthy, their health signature can slightly rise to account for increasing frailty, since health is a short-term marker and frailty captures a larger diagnostic burden.

Ancestry removed from the polygenic scores

We regress the 36 polygenic scores on the first 10 genetic PCs, using one least-squares fit across the whole cohort. We keep the residuals, drop the PCs themselves, and add sex (P = 37). If the PCs are left in, ancestry can move the healthy reference and get mistaken for disease structure.

Where to find the figures, code and definitions

wherewhat
SiteEach main figure has a page showing its scripts. The "Why the triplet" page has the ablation figure, which shows what each piece changes across ancestry groups.
Code (repository private at present)model: src/clust_huge_amp_vectorized_reparam_slope_3way.py; training: src/train_slope_3way.py; held-out prediction: src/triplet_loo_calibration.py. The header of each file explains why each piece is needed.
PreprintThe Methods sections "Health component" and "Frailty" have the full definitions.

The data paths in the code are hard-coded to the authors' machine, so it is best read as a reference for now.


3. How fitting changed: a staged fit that establishes the health component first

Why stage the fit: health and sex can both explain a person with no diagnoses

With a health component, a person with no diagnoses can be explained in two ways: by the health component, or by a large sex coefficient that places men in one quiet signature and women in another. Both fit the training data about equally. The health component fills late in training and the genetic coefficients move early, so small differences decide which explanation is reached.

How it is staged: the sex coefficient is held for the first 150 epochs, then released

The sex coefficient is held at its starting value for the first 150 epochs, so the health component fills first, and is then released. Everything else, including the polygenic coefficients, trains from the first epoch. The model and its likelihood are unchanged; only the order in which parameters may move changes. It is stopped at about 375 epochs, where calibration on held-out people is right (0.99 on each of three random starts).

What changed when the fit was staged

original recipestaged
three random starts on one batchone in the parked stateall three agree, in training and held out
men's health share across six batches chosen to span the spread0.41 to 0.860.69 to 0.71
10-year AUC within sex, median over 221 diseases0.6300.630
observed / expected by epoch, one batch scored on another1.12 at 300, 1.05 at 350, 0.99 at 4001.16 at 300, 1.03 at 350, 0.99 at 375, 0.96 at 400
three random starts at the stop: observed / expected on held-out people1.11, 1.10, 1.30 at 3000.99, 0.99, 0.99 at 375
pooled backbone of four fits, scored on held-out people: observed / expected1.131.04
pooled backbone of four fits: 10-year AUC within sex, median0.6320.631
pooled backbone of four fits: 1-year AUC, the manuscript's 28 groups0.9280.950
pooled backbone of four fits: 10-year AUC, the manuscript's 28 groups0.6840.679

An alternative: average the genetic effects over batches and hold them fixed

A second way to stage it is to average γ over the first-stage batch fits and refit with it held fixed. Two random starts then give the same fit, and held-out prediction matches the original recipe. It takes on the quality of the fits that are averaged, so those are checked first.

Scope of the evidence

Three random starts on one batch; the stop rests on one training batch scored on one group of held-out people; six of 40 batches were refitted. The manuscript's figures use the 300-epoch recipe without the staging; none of its 40 batch fits is fully in the parked state and two are partway.

Before applying any of this to your own data

Where to find the command, the checks and the evidence

How to apply it, with the command and the checks to run on a fit: training notes. Evidence, table by table: training length and stability.