Tutorials › Model-Informed Drug Development (MIDD) › External Validation and Biological Domain Shift

Translational Modeling and Uncertainty · Tutorial 139 of 596

External Validation and Biological Domain Shift

Learn to design external validation that preserves independence, calculate useful prediction metrics, and diagnose biological domain shift without mistaking a performance difference for its cause.

Advanced 12 min read

What You'll Learn

  • Distinguish external validation from internal resampling and explain why the model must be frozen before evaluation.
  • Calculate and interpret mean error, mean absolute error, and root mean squared error in context.
  • Compare validation performance across biologically meaningful subgroups.
  • Identify how chemistry, assay methods, and experimental conditions can create domain shift.
  • Recognize confounding, small validation samples, and other limits on conclusions about transportability.

Why Independent Validation Matters

A translational model can fit its development data well and still predict poorly for a new compound or study. The crucial question is not simply whether the model describes the data used to build it, but whether its predictions remain useful for the intended population of compounds, assays, and experimental conditions. External validation addresses that question by evaluating predictions on data independent of model development.

Independence here concerns the whole modeling process, not just whether a row appeared in the fitting table. If an outcome helped select the model structure, tune parameters, choose a transformation, or decide which compounds to retain, it has influenced development. Evaluating the final model on that same information does not provide an independent test. For a valid evaluation, specify the prediction task and endpoint, freeze the model and its prediction procedure, and then compare its predictions with outcomes from the external data.

Definition: External validation evaluates a prespecified model on independent compounds, experiments, or studies that were not used to fit, select, or tune that model. A validation result describes predictive performance for the tested external data and conditions; it does not by itself establish performance for every future biological domain.

The validation unit must match the intended use. If the goal is to predict for new compounds, holding out measurements while retaining other measurements from those same compounds may overstate performance. If the intended prediction is to a new study, holding out individual observations while including other observations from that study may likewise leak study-specific information. When observations are clustered by compound, laboratory, or study, the split and interpretation should reflect that structure.

Quantifying Prediction Error

For external observation \(i\), let \(y_i\) be the observed endpoint and \(\hat{y}_i\) the prediction made by the frozen model. Define the prediction error as \(e_i=y_i-\hat{y}_i\). A positive error means the model underpredicted the observed value; a negative error means it overpredicted. Errors and summaries must be reported on the endpoint scale relevant to the prediction task.

Key metrics: For \(m\) external observations, mean error (bias) is \(\bar{e}=\frac{1}{m}\sum_{i=1}^{m}e_i\); mean absolute error is \(\mathrm{MAE}=\frac{1}{m}\sum_{i=1}^{m}|e_i|\); and root mean squared error is \(\mathrm{RMSE}=\sqrt{\frac{1}{m}\sum_{i=1}^{m}e_i^2}\). Bias summarizes the average direction of error, MAE the average absolute error, and RMSE an error scale that gives greater weight to large errors.

These metrics answer different questions. Bias near zero does not mean predictions are individually accurate: overpredictions and underpredictions can cancel. MAE is directly interpretable in endpoint units. RMSE is also in endpoint units, but is more affected by large errors. None alone diagnoses why a model missed, whether a few observations dominate performance, or whether predictions are reliable in a particular biological subgroup.

Worked Example: Summarizing Errors on External Compounds

Suppose a frozen model predicts potency, measured as pIC50, for four hypothetical external compounds. The observed and predicted values are:

CompoundObserved \(y_i\), pIC50Predicted \(\hat{y}_i\), pIC50Error \(e_i=y_i-\hat{y}_i\), pIC50
A1091
B1215-3
C810-2
D20164

The mean error is \((1-3-2+4)/4=0\) pIC50 units. Thus, the errors have no net average direction in these four observations; this does not mean each prediction is accurate. The MAE is \((|1|+|-3|+|-2|+|4|)/4=10/4=2.50\) pIC50 units.

For RMSE, square the errors before averaging:

$$ \mathrm{RMSE} =\sqrt{\frac{1^2+(-3)^2+(-2)^2+4^2}{4}} =\sqrt{\frac{30}{4}} =\sqrt{7.5} \approx 2.739\ \text{pIC50 units}. $$

In this hypothetical set, the typical absolute error is 2.50 pIC50 units by MAE, while RMSE is 2.739 pIC50 units because it weights the larger misses more heavily. Four compounds are too few to establish performance broadly; the calculations describe only this small external set.

Diagnosing Biological Domain Shift

External data can differ from development data in ways that change the relationship the model is asked to predict. Domain shift is a difference between the development and validation domains that may affect the model’s inputs, the outcome-generating biology, or the measurement process. In translational work, relevant differences can include chemical scaffolds or target-binding modes, assay platforms and protocols, species or tissue sources, dose or sampling conditions, and laboratory procedures.

A validation error is evidence about prediction in the tested domain, not a diagnosis of its cause. To investigate shift, examine what differs between the development and external data and whether errors vary with those differences. Useful summaries include subgroup-specific bias and MAE, plots of residuals against chemical or experimental features, and comparisons of input ranges and distributions. Such analyses should be planned or interpreted cautiously when subgroups are small; repeated searching for a subgroup that “explains” poor performance can produce an unstable story.

For a continuous feature \(z\), such as a molecular descriptor or assay temperature, compare its development and validation ranges and distributions. A validation value far outside the development range signals extrapolation in that feature, but being within the range does not guarantee that the biological relationships are the same. For categorical features, such as assay platform, identify categories absent from development data. A model cannot learn a platform-specific relationship from a category it never encountered unless its structure contains a justified way to represent that difference.

Worked Example: A Chemistry-Related Performance Difference

Consider six hypothetical external compounds evaluated with the same assay protocol. Three have a familiar chemical scaffold and three have a scaffold absent from the development set. Assume the endpoint is pIC50, and the model was frozen before these outcomes were examined.

GroupObserved pIC50 valuesPredicted pIC50 valuesErrors \(y_i-\hat{y}_i\)
Familiar scaffold11, 11, 910, 12, 81, -1, 1
Unseen scaffold16, 18, 1410, 12, 86, 6, 6

For the familiar-scaffold group, mean error is \((1-1+1)/3=0.3333\) pIC50 units and MAE is \((1+1+1)/3=1.000\) pIC50 unit. For the unseen-scaffold group, mean error and MAE are both \((6+6+6)/3=6.000\) pIC50 units. The errors point in the same direction and are much larger for the unseen scaffold in this hypothetical set.

This pattern is consistent with a chemistry-related domain shift, but it does not prove that scaffold novelty caused the errors. The groups could also differ in unrecorded properties, and six compounds provide limited evidence. A stronger diagnostic design would include compounds that vary in scaffold while keeping the assay protocol and other relevant conditions comparable, and would evaluate further independent compounds from both groups.

Separating Chemistry, Assay, and Study Effects

Several sources of shift can occur together. For example, a new chemical series may be measured in a different assay at a different laboratory. If predictions fail on that series, the external evaluation reveals a problem for that combined domain, but it cannot identify which difference produced the problem. This is a confounding limitation of the comparison, not a flaw that can be repaired by a more elaborate error metric.

Where feasible, use bridging data: the same compounds measured under both assay methods, or comparable compounds measured under matched conditions across studies. Paired measurements can reveal systematic measurement differences while holding compound identity fixed. Replication and reference compounds can help distinguish assay drift from biological variation. These designs do not automatically establish that the model transports to a new biological setting, but they make competing explanations more testable.

Study-level clustering also matters when summarizing performance. If many observations come from one study, treating them as many independent demonstrations of transportability gives that study disproportionate influence. Report how many compounds and studies contribute, show study-specific performance where possible, and avoid interpreting a pooled metric as if every study contributed equally. The appropriate summary depends on the intended prediction task and the distribution of future compounds or studies.

$$ \mathrm{RMSE}^2 =\frac{1}{m}\sum_{i=1}^{m}e_i^2 =\frac{1}{m}\sum_{i=1}^{m}(e_i-\bar{e})^2+\bar{e}^{\,2}. $$

This identity follows by writing \(e_i=(e_i-\bar{e})+\bar{e}\), squaring, and summing. The cross-product term is zero because \(\sum_{i=1}^{m}(e_i-\bar{e})=0\). Thus, squared RMSE combines the average squared spread of errors around their mean with squared bias. A model may therefore have substantial RMSE because of a systematic offset, variable errors, or both. This decomposition helps describe a pattern; it does not identify its biological cause.

Prediction Intervals and External Coverage

When the model provides prediction intervals, external validation can also check whether observed outcomes fall within them. For \(m\) external outcomes with intervals constructed at a nominal level \(1-\alpha\), empirical coverage is the number of observed outcomes inside their corresponding intervals divided by \(m\). Coverage near the nominal level is desirable across repeated comparable predictions, but a small validation set gives a coarse and uncertain estimate. A single miss does not prove the interval procedure is defective, and observed coverage does not verify performance in untested domains.

Worked Example: Interpreting External Interval Coverage

A hypothetical model produces nominal 90% prediction intervals for six independent external compounds. Five observed pIC50 values fall within their corresponding intervals, and one falls below its lower limit. Empirical coverage is \(5/6=0.8333\), or 83.3%.

This is below the nominal 90%, but six observations provide little precision: changing the status of one compound changes coverage by \(1/6=16.7\) percentage points. The result is a reason to inspect the missed compound and the validation domain, not a basis for concluding that true coverage is exactly 83.3% or that the interval method necessarily fails in all settings. Check whether the miss is associated with a new scaffold, assay, or study condition, and seek more independent validation data.

Validation Choices, Diagnostics, and Limits

External validation complements rather than replaces internal resampling. Random train-test splits and cross-validation estimate performance under assumptions about how held-out observations relate to development observations; they can be useful for model development, but they may not represent new compounds or studies if related observations occur on both sides of the split. Leave-one-species-out validation tests a particular form of species transfer. External validation tests performance on independent data from the domain actually assembled. None guarantees success in a different future domain.

ApproachWhat it evaluatesMain caution
Random split or cross-validationPrediction for held-out observations drawn under the split’s sampling structureRelated compounds or studies across folds can make the task easier than the intended use
Leave-one-species-out validationPrediction when a species is omitted from model fittingIt addresses species omission, not every chemical, assay, or study shift
External validationPrediction on independent compounds or studies in the assembled external domainResults may not generalize beyond the tested domain; limited external data may yield unstable summaries

Before interpreting poor external performance, verify data alignment and prediction provenance. Confirm that units, endpoint definitions, transformations, and compound identities are consistent; check for missing or duplicated records; and ensure that predictions were generated without using external outcomes to retune the model. Inspect individual residuals and subgroup patterns rather than relying only on a pooled score. A large error may reflect data quality, an endpoint mismatch, a model limitation, or a genuine biological shift.

If the model is recalibrated using external outcomes, report that as a distinct step. The same outcomes cannot then serve as an untouched external evaluation of the recalibrated model. A separate independent set is needed to evaluate the updated prediction procedure. External validation also cannot establish causal mechanisms for the observed prediction errors, guarantee performance under untested conditions, or compensate for an external set that poorly represents the intended use.

Common Pitfall

Wrong reasoning: “The overall mean error is zero, so the model has no systematic problem and transports well.” This is wrong because positive and negative errors can cancel, and one subgroup can be poorly predicted while another offsets its bias. In the four-compound example, mean error was zero even though individual errors ranged from \(-3\) to \(4\) pIC50 units.

Correction: Report direction and magnitude together, inspect residuals and relevant subgroups, and describe exactly which compounds, studies, and conditions were evaluated. A low overall error is useful evidence for the tested data, not proof of transportability to every biological domain.

Key takeaway: Freeze the model before external evaluation, measure errors on the intended endpoint scale, and investigate differences in chemistry, assays, and experimental conditions. Treat a domain-shift explanation as a hypothesis to test, especially when multiple domain features change together.

Check Your Understanding

Answer each question, then compare with the worked solutions below.

  1. For three external outcomes \(y=(7,11,10)\) and predictions \(\hat{y}=(8,9,12)\), calculate the errors, mean error, MAE, and RMSE.
  2. Eight of ten observed outcomes fall within their nominal 90% prediction intervals. What is empirical coverage, and what should be concluded?
  3. A model is tuned using outcomes from an external study, then evaluated on the same study. Is this still an independent external validation? Explain.
  4. A new chemical series is measured using a new assay platform, and the model performs poorly. Can the error be attributed to chemistry alone? What additional design could help?

Solutions. (1) Errors are \(7-8=-1\), \(11-9=2\), and \(10-12=-2\). Mean error is \((-1+2-2)/3=-1/3=-0.3333\) endpoint units; MAE is \((1+2+2)/3=1.667\) units; RMSE is \(\sqrt{(1+4+4)/3}=\sqrt{3}=1.732\) units. (2) Coverage is \(8/10=80.0\%\). It is below nominal 90% in this small set, but the estimate is imprecise and does not establish coverage in other domains. (3) No. The outcomes influenced tuning, so evaluating on the same study is not independent; evaluate the tuned procedure on another untouched set. (4) No. Chemistry and assay changes are confounded in this comparison. Measure bridging compounds across assay methods, or compare compounds with scaffold differences under matched assay conditions, then validate on further independent data.