Guides / QSAR and machine learning

applicability-domainqsaruncertainty

Applicability domain, when a QSAR model should refuse

The applicability domain is the region of chemical space where a model's predictions can be trusted. Learn the common ways to define and test it.

Updated 4 min read

The applicability domain is the region of chemical space where a model's predictions can be trusted, and a well-built QSAR service checks it for every query and declines or flags molecules outside it. Without that check, a model returns a confident-looking number for anything, including molecules that look nothing like its training set.

Why every model needs one

A regression is a function. Give it a descriptor vector and it returns a value, whether or not that vector resembles anything it was fitted on. A model of aqueous solubility trained on small neutral organics will still print a number for a peptide or a metal complex. The number is not wrong in a visible way. It is simply meaningless.

The OECD lists a defined domain of applicability as one of five validation principles for QSAR models used on chemicals. The idea applies just as well to a medicinal chemistry project. A potency model trained on one kinase series is valid for that series and its neighbours, and nowhere else.

Four practical ways to define a domain

  1. Descriptor ranges. Record the minimum and maximum of each descriptor in the training set and flag queries with any value outside. This is simple, but it uses a bounding box. A query can sit inside every range and still be far from all data, because the box includes empty corners.
  2. Leverage. For a linear model, the hat matrix gives each compound a leverage that measures how far it sits from the centre of the training data in descriptor space. A common warning level is three times the number of model parameters divided by the number of training compounds. Plotting standardised residuals against leverage gives the Williams plot.
  3. Nearest-neighbour similarity. Compute the Tanimoto similarity between the query and its closest training compounds, as described in Morgan fingerprints and the Tanimoto coefficient. If the nearest neighbour is below a threshold, flag the prediction.
  4. Ensemble disagreement. Train several models, for example a random forest with many trees or models from different seeds, and treat the spread of their predictions as an uncertainty signal. High spread suggests extrapolation.

Distance-based and ensemble methods suit fingerprint models. Leverage and ranges suit small descriptor models.

A nearest-neighbour check in code

import numpy as np
from rdkit import Chem, DataStructs
from rdkit.Chem import rdFingerprintGenerator

gen = rdFingerprintGenerator.GetMorganGenerator(radius=2, fpSize=2048)
train_fps = [gen.GetFingerprint(Chem.MolFromSmiles(s)) for s in train_smiles]

def nearest_similarity(smiles, k=3):
    fp = gen.GetFingerprint(Chem.MolFromSmiles(smiles))
    sims = DataStructs.BulkTanimotoSimilarity(fp, train_fps)
    return float(np.mean(sorted(sims, reverse=True)[:k]))

def in_domain(smiles, threshold):
    return nearest_similarity(smiles) >= threshold

The threshold is the hard part, and no value works for every model. Choose it from the data. Run a cross-validation, record each held-out compound's mean similarity to its nearest training neighbours and its prediction error, and plot error against similarity. Pick the similarity below which the error grows past what your decision tolerates. For a model that guides synthesis, that error might be half a log unit. For a coarse triage, it can be larger.

What to do with an out-of-domain query

Do not hide it. Return the prediction with a flag, or no prediction and a reason. A short message such as "nearest training compound has Tanimoto similarity 0.21" gives the user something to act on, and a chemist can then decide to measure instead.

The domain should also cover the endpoint. A model trained on potencies between 5 and 8 in pIC50 will not predict a 10 well, because tree-based models cannot output values beyond what they have seen. That is response-space coverage, and it is easy to forget.

Limits of the idea

An applicability domain is a necessary check and not a guarantee. Inside the domain, a model can still fail on an activity cliff, where a tiny change causes a large shift. Similarity thresholds are also fingerprint-dependent, so the same query can be inside the domain under one fingerprint and outside under another. Document which representation the check used.

Embedding-based tools offer another view. If you project your training and query molecules into a low-dimensional map, as in chemical space exploration with UMAP, you can see whether a new compound lands in a populated region or on an empty edge. Treat the map as a visual aid and keep the numeric check as the rule.

Where a model is exposed as a service, store the domain information with it. QSAR training and prediction in Advanced Modeling is easiest to use well when you also keep the training table, so that a nearest-neighbour check can be recomputed for any new query.

A worked reading of a flag

Suppose a solubility model trained on drug-like neutral molecules receives a query for a large macrocycle. The mean similarity to its three nearest training compounds is low, its molecular weight is above every training value, and the forest trees disagree widely. Three independent checks agree, so the service should return a flag and no confident number. If only one check fires, for example a single descriptor slightly outside its range, a softer warning is enough. Combining checks this way avoids refusing too often and avoids trusting a single noisy rule.

Key points

Questions people ask

What is the applicability domain of a QSAR model?
It is the part of chemical and response space in which the model was built and in which its predictions are expected to be reliable. A query molecule inside the domain is an interpolation, and one outside it is an extrapolation with unknown error.
How do you define an applicability domain?
Common approaches are the range of each descriptor in the training set, the leverage of the query in descriptor space, the similarity of the query to its nearest training compounds, and the disagreement of an ensemble of models. Several are often combined.
Why does a QSAR model give a number for any molecule?
Most algorithms are functions that return an output for any input. Nothing in the algorithm checks whether the input resembles the training data, so the check has to be added deliberately.
Is applicability domain required by the OECD?
The OECD principles for the validation of QSAR models list a defined domain of applicability as the third principle. Regulatory use of a model for chemicals is expected to document it.

Further reading

In practice: Advanced Modeling trains and applies QSAR models; the AI Foundry runs or fine-tunes ChemBERTa, MoLFormer-XL and Chemprop on a CSV, as a preview. Validation is the user's responsibility, and these guides show how.

← All guides