MolBasis
standardisationz-scorepreprocessingunits5 min read

z-scoring and standardisation before a regression fit

z-scoring subtracts the training mean and divides by the training spread after the exponent. Store both or the equation cannot be applied to new molecules.

Updated November 28, 2026

z-scoring subtracts the mean and divides by the standard deviation, so that every column enters the fit on the same scale. For a property kernel the two statistics must be computed on the training molecules, after the exponent is applied, and stored next to the coefficients. An equation without its means and spreads cannot be applied to a new molecule, and an equation applied with the wrong unit produces a z-score that is silently and badly wrong. This guide covers the order of operations, the choice of standard deviation, and the unit case with the arithmetic shown.

What the transformation does and why the order matters

For a column t the standardised value is z = (t − μ)/σ, where μ and σ are the mean and standard deviation of t over the training set. The standardised column has mean zero and standard deviation one, whatever t was measured in.

In a kernel the column t is f^p, the descriptor raised to its exponent. The standardisation must come after the power. Take the toy descriptor f = 4, 9, 16, 25, 36 with p = 0.5. The correct route takes √f = 2, 3, 4, 5, 6, then standardises to −1.414, −0.707, 0, 0.707, 1.414. The wrong route standardises f first. Its mean is 18 and its deviations are −14, −9, −2, 7, 18, three of them negative. The square root of a negative deviation is not a real number, and even where it exists, the column differs from the correct one. The guide on power-law terms and exponent grids covers the conventions for descriptors that are negative to begin with.

Population or sample standard deviation

Two formulas compete. The population form divides the sum of squared deviations by n. The sample form divides by n − 1. NumPy's std and scikit-learn's StandardScaler use the population form by default. Pandas' std uses the sample form. R's sd uses the sample form.

On five points the ratio between them is √(5/4) = 1.118. A coefficient fitted on columns standardised one way is 12 % larger or smaller than the same coefficient fitted the other way, with identical predictions. Neither is wrong. Mixing them is. If the fit used the population form and the application uses the sample form, every z-score shrinks by 12 % and every prediction is pulled toward the mean.

The lesson is procedural. Record which form was used, or better, record μ and σ as numbers and skip the question when applying.

Units cancel in z-scoring, until you mix them

Multiplying a column by a constant c multiplies both the deviations and σ by c, so z is unchanged. This is why a descriptor stored in bohr² gives the same standardised coefficient as the same descriptor in Ų. The fit does not care about the unit.

Application cares a great deal. Take three training areas of 600, 800 and 1000 bohr². The mean is 800 and the population standard deviation is √(80000/3) = 163.3. Now a new molecule arrives with an area of 250 Ų. In bohr² that is 250/0.2800 = 892.9, so the correct z is (892.9 − 800)/163.3 = 0.569. Feed the Ų value in by mistake and z becomes (250 − 800)/163.3 = −3.37. A molecule slightly above the training mean is treated as an extreme outlier far below it, and the prediction is nonsense without any error message.

This is the exact trap in the mfsig v0.91.1 files. The field named cavity_area_aa2 holds bohr², and the current mfsig recipe writes ångström. Any kernel standardised on the old files and applied to new ones would need the conversion first. The guide on the bohr versus ångström units trap and the mfsig guide on units and unit errors in mfsig files give every factor, including × 3.571 for σ and × 12.75 for its variance.

What must travel with the equation

A kernel is not ŷ = β₀ + β₁·z(f^p) alone. To apply it you need, for each term, the descriptor name and its definition version, the exponent and the convention for negative values, the training mean and standard deviation of f^p, the form of the standard deviation, and the unit the training files used. Then the coefficients. Then the training mean of the property, which is β₀.

MolBasis does not publish the coefficients or the training statistics, so its kernels cannot be applied from the site. The guide on why the coefficients matter explains what follows from that, and the guide on how to apply a property kernel lists the steps for an equation whose numbers you do have.

The code for a correct application is short once the numbers exist.

import numpy as np
# fitted on training data, stored with the equation
p, mu, sd, beta0, beta1 = 0.5, 4.0, 1.4142, 2.0, 0.693
f_new = np.array([49.0, 64.0])
t_new = f_new ** p
z_new = (t_new - mu) / sd
y_hat = beta0 + beta1 * z_new

Note what is absent. No t_new.mean() and no t_new.std(). A new molecule is never standardised against itself or against its batch.

Key points

  • Standardise after the exponent, not before. The two orders give different columns, and the wrong one fails on negative deviations.
  • Population and sample standard deviations differ by √(n/(n − 1)). Use one consistently and record it.
  • A constant unit factor cancels in z-scoring, so the fitted coefficient is unit-free. Applying with a different unit than training breaks the z-score silently.
  • The equation travels with its training means and spreads, its units and its definitions. Without them it cannot be applied.

Questions people ask

Why standardise descriptors before a ridge fit?
So that every column enters on the same scale. The ridge penalty and the comparison of coefficients both assume comparable columns, and a descriptor in bohr² would otherwise swamp one in debye.
Do I standardise before or after raising to the exponent?
After. The kernel form is z of f to the power p. Standardising first produces negative values that a fractional power cannot take, and the two orders give different columns.
Population or sample standard deviation?
Either, as long as the same choice is used for fitting and for applying and the choice is recorded. NumPy and scikit-learn default to the population form, pandas to the sample form, and on five points they differ by 12 %.

Further reading

In practice: A kernel on this site is one or two descriptor terms with coefficients from a single ridge solve. The methodology page gives the exact form, the grid and the gate the search had to pass.

See the kernels themselves

Every kernel is shown with its held-out result, the number of molecules it rests on and what it cannot be trusted for.