uncertainty-qsar
Skill6 starsChanged 9 months agoMITView on GitHub
Use when building QSAR/ML models that need calibrated uncertainty estimates. Covers epistemic vs aleatoric uncertainty theory, conformal prediction with MAPIE (guaranteed coverage), Gaussian processes with Tanimoto kernel, deep uncertainty (MC dropout, deep ensembles, Laplace), and applicability domain (AD) assessment. Critical for active learning and reliable property prediction.
- Installs packages
In this repository27 other files it gives its agents.
- config/CLAUDE.mdCLAUDE.md
- active-learningSkill
- aseSkill
- binding-kineticsSkill
- chem-brainstormSkill
- coarse-grainedSkill
- daylight-theorySkill
- deepchemSkill
- dockingSkill
- fbddSkill
- force-fieldsSkill
- free-energySkill
- generative-designSkill
- homology-modelingSkill
- lit-rescueSkill
- mdanalysisSkill
- mmpaSkill
- nextflowSkill
- openbabelSkill
- organic-mechanismsSkill
- pepflexSkill
- pharmacophoreSkill
- py3DmolSkill
- qm-dftSkill
- rdkitSkill
- synkitSkill
- torchdrugSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 115
Conformal requires i.i.d. calibration: if training/calibration sets have distribution shift, coverage guarantee breaks
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Uncertainty-Aware QSAR
QSAR models that output only point predictions are insufficient for drug discovery decisions. Uncertainty quantification (UQ) transforms predictions into actionable confidence intervals: "LogD = 2.3 ± 0.4 (90% CI)" is far more useful than "LogD = 2.3".
When to Use This Skill
- Build QSAR models with calibrated prediction intervals (not just point predictions)
- Assess whether a query molecule is within the applicability domain (AD) of the model
- Design active learning loops: prioritize compounds with high epistemic uncertainty
- Rank compounds when model uncertainty is high (don't trust raw predictions alone)
- Regulatory/submission context requiring prediction confidence bounds
- Compare model calibration (is the stated 90% CI actually 90% coverage?)
Uncertainty Types
| Type | What it means | How to reduce | Methods |
| Epistemic | Model doesn't know (lack of training data) | Add more training data | GP variance, ensemble disagreement, MC dropout std |
| Aleatoric | Intrinsic noise (measurement error) | Can't be reduced | Heteroscedastic models, learned noise σ |
| Total | Combined uncertainty | — | Epistemic + Aleatoric in prediction |
Quick Start — Conformal Prediction (MAPIE)
from mapie.regression import MapieRegressor
from sklearn.ensemble import RandomForestRegressor
import numpy as np
# Fit + calibrate
base_model = RandomForestRegressor(n_estimators=100, random_state=42)
mapie = MapieRegressor(base_model, method="plus", cv=5)
mapie.fit(X_train, y_train)
# Predict with intervals (alpha = desired error rate)
y_pred, y_pi = mapie.predict(X_test, alpha=0.10) # 90% CI
# y_pi shape: (n_samples, 2, n_alpha)
lower = y_pi[:, 0, 0]
upper = y_pi[:, 1, 0]
# Coverage check
coverage = np.mean((y_test >= lower) & (y_test <= upper))
print(f"Empirical coverage: {coverage:.2%}") # should be ~90%Quick Start — Tanimoto GP
import gpytorch
import torch
from rdkit.Chem import rdMolDescriptors
class TanimotoKernel(gpytorch.kernels.Kernel):
"""Tanimoto similarity kernel for binary fingerprints."""
has_lengthscale = False
def forward(self, x1, x2, **params):
x1_sum = x1.sum(-1, keepdim=True)
x2_sum = x2.sum(-1, keepdim=True)
dot = torch.matmul(x1, x2.transpose(-1, -2))
intersection = dot
union = x1_sum + x2_sum.transpose(-1, -2) - dot
return intersection / union.clamp(min=1e-8)
# Usage:
# fps = np.array([get_morgan_fp(smi) for smi in smiles_list])
# X = torch.tensor(fps, dtype=torch.float32)
# y = torch.tensor(activities, dtype=torch.float32)
# → see references/gaussian-processes.md for full GP modelRouter — What to Read
| Task | Reference |
| Theory: epistemic vs aleatoric, GP kernel validity, conformal coverage proof, AD concepts | references/uncertainty-theory.md |
| Conformal prediction with MAPIE: split/cross conformal, regression/classification, calibration | references/conformal-prediction.md |
| GP regression with Tanimoto kernel: GPyTorch, hyperopt, posterior sampling, active learning | references/gaussian-processes.md |
| Deep uncertainty: MC dropout, deep ensembles, evidential regression, Laplace approximation | references/deep-uncertainty.md |
| Applicability domain: distance-based AD, Williams plot (leverage), visualization, thresholds | references/applicability-domain.md |
Software Stack
| Package | Install | Role |
MAPIE | pip install mapie | Conformal prediction (classification + regression) |
gpytorch | pip install gpytorch | GP models on PyTorch (GPU-ready) |
botorch | pip install botorch | Bayesian optimization (uses GPyTorch) |
laplace-torch | pip install laplace-torch | Laplace approx for any PyTorch model |
torch | pip install torch | Deep ensembles, MC dropout |
sklearn | pip install scikit-learn | RF/SVM baselines, calibration |
rdkit | conda/pip | Fingerprints (Morgan, MACCS) for features |
uncertainty-toolbox | pip install uncertainty-toolbox | Calibration plots, ECE, sharpness |
Key Concepts Summary
| Concept | Formula / Key Point |
| Coverage guarantee | P(y ∈ Ĉ(x)) ≥ 1−α for conformal (finite-sample) |
| Prediction interval | [ŷ − q̂, ŷ + q̂] where q̂ = (1−α) quantile of calibration residuals |
| GP posterior variance | σ²(x*) = k(x*,x*) − k(x*,X)[K+σ²I]⁻¹k(X,x*) |
| Ensemble uncertainty | σ²_epistemic = Var{f̂_m(x)} across M models |
| MC dropout σ | std of T forward passes with dropout active |
| Leverage h_ii | h = x(XᵀX)⁻¹xᵀ; Williams plot flags h > 3p/n |
| AD distance | D = min_train Tanimoto; D < threshold → inside AD |
Key Pitfalls
- Overconfident RF: RF standard deviation of tree predictions is NOT a calibrated CI — always use conformal on top
- GP scaling: naive GP is O(n³) — for >5000 training points use sparse GP (inducing points) or
ExactGP+ KeOps - Conformal requires i.i.d. calibration: if training/calibration sets have distribution shift, coverage guarantee breaks
- MC dropout depth: dropout only captures epistemic if placed at multiple layers; single output layer dropout ≈ ensemble of linear heads only
- AD threshold is task-specific: there is no universal threshold for "inside AD" — always validate on held-out temporal/spatial split
Related Skills
scientific-skills:scikit-learn— RF/SVM/GBM base models, cross-validationscientific-skills:pymc— full Bayesian QSAR (MCMC-based posterior)active-learning(upcoming) — using uncertainty for experimental designmmpa— MMPA + uncertainty: only apply transforms where model is confidentgenerative-design— uncertainty filter on generated molecules (discard low-confidence predictions)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

