/dsm-soil:spatial-prediction-uncertaintyfrom dsm-soil
Quantifies and maps spatial ML prediction uncertainty on two axes: distributional (prediction intervals) and epistemic coverage (AOA, DI, LPD). For digital soil maps, nutrient maps, or any raster ML product needing per-pixel uncertainty.
Ships in dsm-soil. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Forged from the DSM knowledge wiki (sources 2021–2025). The wiki stays the source of truth; this skill is the distilled, operable version. Core pages: predictive-uncertainty, area-of-applicability, local-data-point-density, quantile-regression-forests, probabilistic-scoring, conformal-prediction, spatial-cross-validation, cast.
Scope boundaries. General cross-validation, accuracy metrics, and uncertainty aggregation live in soil-map-validation — defer to it for those. This skill owns the uncertainty product itself: what to compute, how the two axes fit together, and how to ship a map that states where it is applicable, not only what it predicts. It is also the engine of Pillar C in soil-fertility-mapping.
Uncertainty has two axes, and the most common tools cover only one of them.
The load-bearing warning (Meyer & Pebesma 2021): QRF intervals and RF ensemble SD are blind to extrapolation — their spatial patterns disagree with the true error where the model predicts into unseen environments. So a pixel can have a tight interval and still be wildly wrong because it is far outside the AOA. Within-model variability ≠ out-of-domain uncertainty. Report both axes or the map lies about where it's guessing. Full frame: predictive-uncertainty.
For clustered legacy data (the national-mapping norm), the coverage axis is the decisive one: most of the country is predicted far from any sample, and only the AOA/LPD layer flags it.
1. Frame it. State the property, support, and what uncertainty means for the decision — a field-scale recommendation needs a tighter, better-covered map than a regional gradient. Decide the nominal interval (e.g. PI90) and the performance level you'll require.
2. Get an honest CV FIRST — it sets everything downstream. Choose the CV to match the sampling structure: kNNDM (CAST default; auto-adapts — random on random samples, spatial on clustered) or spatial-block CV. This is not optional housekeeping: the AOA threshold is derived from CV nearest-neighbour distances, so a mismatched CV (random CV on clustered data) corrupts the error estimate and the applicability map. Defer the metric panel to soil-map-validation.
3. Distributional axis — per-pixel intervals.
4. Coverage axis — mask and grade (the CAST core).
aoa() under the same CV as step 2.
Mask every prediction map to the AOA — outside it, the CV error simply does not hold.aoa(newdata, model, LPD = TRUE): it counts
how many training points support each pixel, graduating reliability inside the AOA. It predicts
error better than DI alone (R² 0.74/0.71 vs 0.57/0.40) and exposes low-DI-but-thin-support zones a
binary AOA waves through.5. Combine and communicate. Ship, together: the prediction, its prediction interval (distributional), the AOA mask + LPD/DI performance layer (coverage). Annotate: "inside the AOA the CV performance holds on average; low-LPD areas carry higher uncertainty; outside the AOA the map is extrapolation." One layer without the other is half a product.
6. Act on it (active learning). Low-LPD / high-DI zones inside the target area are where new
samples buy the most — epistemic uncertainty is reducible. Feed those maps into
sampling design to target the next campaign; trainDI() lets you test a
proposed design's effect on the AOA cheaply, without refitting.
| Function | Does |
|---|---|
knndm() / nndm() | fold assignment matching CV↔prediction nearest-neighbour distances (honest AOA threshold) |
ffs() | spatial forward feature selection (target-oriented CV) |
aoa(newdata, model) | DI + AOA for a prediction stack (weights by the model's variable importance) |
aoa(newdata, model, LPD = TRUE) | adds per-pixel LPD |
trainDI() | precompute training DI/threshold — assess a new area/design without recomputation |
DItoErrormetric() | calibrate DI (or LPD) → expected RMSE for a performance map |
CASTvis::exploreAOA() | interactive DI/LPD/AOA exploration |
| You need… | Reach for |
|---|---|
| Per-pixel interval, one forest, sparse legacy data | QRF |
| Per-pixel error across many properties / a stacked model | ensemble spread |
| Valid intervals on an arbitrary trained model, no retraining | conformal prediction (mind exchangeability) |
| "Where does my CV performance even hold?" | AOA + DI |
| "How well-supported is each in-AOA pixel?" | LPD |
| Score/compare probabilistic predictions properly | CRPS / pinball |
| Decide where to sample next | LPD/DI map → sampling design |
| Push property uncertainty into a derived class/index (nonlinear) | Monte-Carlo propagation (spup) |
Distilled from: Meyer & Pebesma 2021 (⭐ AOA + DI; ensemble-SD blind to extrapolation; CV-dependence;
DI→performance calibration), Schumacher et al. 2025 (LPD; beats DI at predicting error; CAST
aoa(LPD=TRUE), kNNDM), Tyralis & Papacharalampous 2024 (predictive distributions; proper scoring
rules — CRPS, pinball), Weytjens 2025 (epistemic vs aleatoric; conformal prediction), with QRF/ensemble
uncertainty from Vaysse 2017, Hengl 2021, Hounkpatin 2022 and the wiki's DSM machinery
(spatial-cross-validation, accuracy-metrics, sampling-design,
model-interpretability). Defers general validation to
soil-map-validation and serves as Pillar C of
soil-fertility-mapping. Propagating per-pixel uncertainty into a
derived class (e.g. fertility class) is now grounded as monte-carlo-uncertainty-propagation (tool:
spup); the ⏳ left is a worked national example. Full citations in the wiki sources/.
Portable build from the DSM knowledge wiki (the source of truth). Obsidian cross-references were flattened for standalone use; regenerate with build.ps1.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ccarbajal16/soil-dsm-skills --plugin dsm-soil12 skills in this plugin
/digital-soil-mapping-workflowRun a digital soil mapping (DSM) project end to end — from framing the target and assembling scorpan covariates, through sampling design, model selection, handling spatial autocorrelation, training, and producing a map with calibrated uncertainty. Use when planning or reviewing any project that predicts a soil property (SOC, texture, pH, …) across space (and optionally time) from environmental covariates. Triggers: "digital soil mapping", "DSM", "predict soil property from covariates", "soil map", "scorpan", "which model for soil mapping", "covariates for soil", "map SOC / soil carbon"./ensemble-ml-for-soilDecide whether to combine machine-learning models at all, and if so how — by measuring the gain available before building any combiner. Covers the ambiguity/diversity ceiling, the weighting spectrum (simple average, R²-weighted, Bates–Granger, AIC/BIC, NNLS/SuperLearner, Granger–Ramanathan, learned meta-models, attention, per-pixel selection), out-of-fold stacking under spatial CV, cross-fitting the combiner, voting for classification, and significance testing of the margin. Use when someone proposes an ensemble, reports an ensemble gain, or asks whether their averaging scheme is "too simple". Triggers: "ensemble machine learning", "model stacking", "stacked generalisation", "SuperLearner", "meta-learner", "meta-model", "weighted average ensemble", "R2-weighted ensemble", "simple average ensemble", "Bates-Granger", "Granger-Ramanathan", "NNLS weights", "non-negative least squares", "caretStack", "mlr3pipelines stacking", "voting ensemble", "hard voting", "soft voting", "blending", "bagging vs boosting vs stacking", "ensemble gain", "does stacking help", "combine RF and XGBoost", "which model to combine", "base learner diversity", "error correlation", "out-of-fold predictions", "level-one dataset", "landmap", "MACHISPLIN", "spatial ensemble", "per-pixel model selection", "combine my model with SoilGrids"./hybrid-process-ml-socDesign and build hybrid soil-organic-carbon models that fuse a process-oriented model (RothC / CENTURY / Millennial) with machine learning (Random Forest / QRF) to predict SOC stock in space AND time — getting ML's spatial accuracy together with the process model's physically-plausible temporal dynamics. Use when a task needs SOC *change* over time (not just a static map), when pure ML gives implausible temporal trends, or when integrating mechanistic knowledge into data-driven soil mapping. Triggers: "hybrid soil carbon model", "process + machine learning", "POML", "space-time SOC", "RothC + random forest", "physically plausible SOC prediction", "knowledge-guided ML for soil"./ml-for-soil-predictionChoose, tune, and reason about machine-learning models for predicting soil properties (SOC, texture, pH, …) — Random Forest, Quantile Regression Forests, gradient boosting, and deep learning — including per-pixel uncertainty and interpretability. Use when the task is the ML modelling craft itself: which algorithm, how to tune it, how to get honest uncertainty, whether deep learning is worth it, why an ML model underperforms. Triggers: "random forest for soil", "QRF", "which ML model", "deep learning soil", "CNN / ANN soil carbon", "hyperparameters", "feature importance / SHAP", "prediction interval", "ML model gives bad R²"./rothc-temporal-modellingSet up, initialize, calibrate, validate, and interpret the RothC (Rothamsted Carbon) model — and CENTURY-family process models — for simulating soil organic carbon stock and its change over time. Use when modelling SOC dynamics under management or climate scenarios, initializing RothC pools (spin-up), calibrating decay constants, choosing carbon inputs, adapting RothC to a region/practice, or judging whether a RothC result is trustworthy. Triggers: "RothC", "CENTURY / CenW", "soil carbon model", "carbon pools DPM/RPM/BIO/HUM/IOM", "spin-up / initialize SOC pools", "calibrate RothC", "SOC under climate change", "carbon input estimation", "first-order decay"./soc-stock-mrvQuantify, report, and verify soil-organic-carbon stock and its change over time for carbon markets / MRV (Monitoring, Reporting, Verification) — computing SOC stock, estimating change and its uncertainty at the field/project support, and applying the uncertainty deduction that determines creditable tons. Use when a task involves soil carbon crediting, an MRV framework (VM0042, VT0014), SOC stock-change detectability, or reporting SOC with defensible uncertainty. Triggers: "SOC MRV", "soil carbon credits", "carbon farming verification", "SOC stock change", "uncertainty deduction", "how much SOC can we credit", "monitoring reporting verification soil carbon".Other plugins' skills for the same job