In-sample versus held-out, the one distinction a report needs
An in-sample figure is computed on the molecules the model was fitted on. A held-out figure uses molecules it never saw. Only the second measures prediction.
Updated November 28, 2026
An in-sample figure is computed on the same molecules that were used to fit the coefficients and, usually, to choose the equation. A held-out figure is computed on molecules that played no part in either step. Only the held-out figure estimates how the model will do on a molecule it has never seen. Every QSPR report needs to label which of the two it is quoting, because the first is almost always higher and the difference is not a detail.
Two sources of optimism in an in-sample number
The first source is the fit itself. Least squares, ridge and every other estimator choose coefficients that minimise the error on the training points. The training error is therefore the minimum achievable error on those points, not a typical error on fresh points. With two coefficients and fifty molecules the effect is modest. With two coefficients and eight molecules it is large.
The second source is bigger and less visible. When a search tries hundreds or thousands of candidate equations and keeps the one with the best score, the winner is partly the equation whose noise happened to align with the target. The in-sample score of the winner is biased upward by the size of the search. The guide on feature selection by search treats this effect in detail. A short equation with two terms can still be the product of a large search, and the search is part of the model.
A worked example on eight points
Fit a straight line on five training points. x = 1, 2, 3, 4, 5 and y = 1.2, 1.9, 3.2, 3.8, 5.1. The mean of x is 3 and the mean of y is 15.2 / 5 = 3.04. The slope is the sum of the products of x minus 3 and y minus 3.04, over the sum of the squares of x minus 3. The products are 3.68, 1.14, 0, 0.76 and 4.12, totalling 9.70. The denominator is 4 + 1 + 0 + 1 + 4 = 10. Slope 0.97, intercept 3.04 − 0.97 × 3 = 0.13.
Fitted values are 1.10, 2.07, 3.04, 4.01 and 4.98. Residuals are 0.10, −0.17, 0.16, −0.21 and 0.12. In-sample MAE is 0.76 / 5 = 0.152.
Now three held-out points, x = 6, 7, 8 and y = 5.4, 7.9, 7.6. Predictions are 0.13 + 0.97 × 6 = 5.95, then 6.92, then 7.89. Errors are −0.55, 0.98 and −0.29. Held-out MAE is 1.82 / 3 = 0.607, four times the in-sample value. Nothing was done wrong here. The held-out points were simply noisier and further out, and the in-sample number had no way to know.
import numpy as np
from sklearn.linear_model import LinearRegression
x_tr = np.array([[1], [2], [3], [4], [5]]); y_tr = np.array([1.2, 1.9, 3.2, 3.8, 5.1])
x_te = np.array([[6], [7], [8]]); y_te = np.array([5.4, 7.9, 7.6])
m = LinearRegression().fit(x_tr, y_tr)
print(np.mean(np.abs(y_tr - m.predict(x_tr)))) # about 0.15
print(np.mean(np.abs(y_te - m.predict(x_te)))) # about 0.61What makes a set truly held out
A held-out set has to be set aside before anything else happens, and it has to stay untouched until the final figures. Three leaks are common. The descriptors or their exponents are chosen on the full data, then the coefficients are refitted on the training part. Outliers are removed after looking at full-data residuals. Or the test set is evaluated many times during development and the best run is reported. Each of these turns a held-out set back into an in-sample set in disguise.
The split also has to respect chemistry. A random split places near-duplicates on both sides, as the guide on random splits and leakage shows, and a scaffold split is the usual remedy. The MolBasis methodology sets aside 25 percent of unique Bemis-Murcko scaffolds with one seed before fitting. The equation the gate selected on the remaining 75 percent is then refitted on that 75 percent, and Pearson r, MAE lift and calibration slope are measured once on the held-out molecules.
How a kernel page separates the two figures
Each kernel page gives the held-out result first and the in-sample figure second, labelled as such, together with the number of held-out molecules the result rests on. The guide on reading a kernel page walks through the layout. The guides do not repeat the figures, because the fitting scripts and result files are not available for review and the figures are reported from the research record rather than recomputed.
The site's findings page records a case where this distinction failed in practice. Three two-term equations had been fitted on the full data and shown as if they were validated. They are now shown as one-term equations, with the correction described. The lesson is not that two-term equations are bad. It is that a figure without a clear in-sample or held-out label cannot be trusted either way.
What to do when the data are too few to split
Sometimes a dataset is so small that a held-out set of 25 percent of scaffolds leaves a handful of molecules. The temptation is to skip the split and report in-sample. Resist it. Report the in-sample figure as in-sample, add a grouped cross-validation estimate, and state the number of held-out molecules even when it is tiny. A small honest number is worth more than a large unlabelled one. The guide on which figure to quote gives wording for both cases.
Key points
- In-sample figures are optimistic twice, once from the fit and once from the search that picked the equation.
- A held-out set is set aside before any fitting or selection, respects scaffolds, and is evaluated once.
- The gap between in-sample and held-out is informative and should be shown, with the in-sample figure labelled secondary.
- Choosing descriptors or removing outliers on full data turns a held-out set back into an in-sample one.
- When the held-out set is tiny, report it anyway with its size, and add a grouped cross-validation estimate.
Questions people ask
- What does held-out mean in model validation?
- Held-out molecules are set aside before any fitting or model selection and are touched once, to compute the final figures. The model never sees their property values during the search for descriptors, exponents or coefficients. A figure computed on them estimates performance on new molecules.
- Why is an in-sample r always higher than a held-out r?
- The coefficients were chosen to fit those exact points, and when a search over many candidate equations picks the best one, it also picks the one whose noise happened to line up with the target. Both effects inflate the in-sample figure. On new molecules neither helps, so the held-out figure drops.
- Is a cross-validation figure in-sample or held-out?
- It sits between the two. Each fold is held out from its own fit, which is good. But if the cross-validation score was used to choose among candidate models, the chosen model's score is optimistic, and only a nested scheme or a final untouched test set restores an honest estimate.
- Should a model page show the in-sample figure at all?
- Yes, as a secondary value and clearly labelled. The gap between in-sample and held-out is itself informative. A small gap suggests a stable equation, a large gap suggests the search or the coefficients fitted noise.
Further reading
In practice: The methodology page describes the checks applied to every kernel, scaffold-blind split included, and the limits of those checks. Every kernel page quotes the held-out figure first and the in-sample figure second.
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.