/geoml:geomlfrom geoml
Provides working knowledge of the geoML Python package for variational Gaussian processes in spatial data, implicit geological modelling, block models, drillhole data, and cross-validation. Use for writing modelling code, choosing kernels/warping/likelihoods, or navigating the package.
Ships in geoml. 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.
Read when SKILL.md points to them.
How to use the geoML package: the object model, the workflow, the recommendations and the geostatistical intuitions its API takes for granted. It says what to build and why. It does not list arguments: the installed package answers that exactly, through its catalogue (§0). Where anything here disagrees with the code, trust the code.
Writing a notebook or example code? Read references/notebook-style.md
first, for the import aliases, the workflow arc, the plotting conventions
and the tree paths. Worked examples are the manual's chapters, in
references/manual/, each run against the package at every release (§4).
Every class and function a model or a script may use is described by the installed geoML itself: arguments, defaults, bounds, how a node's size follows from its arguments, which parents it takes, and how stable it is. Ask it rather than guessing, and before writing any constructor call:
python -m geoml.catalogue --show BoxCox # one entry, as text
python -m geoml.catalogue --show BasicGP --json # the same, as JSON
python -m geoml.catalogue --list # the categories
python -m geoml.catalogue --list warping # one category's entries
A short name that means two things (Gaussian is a kernel and a likelihood)
lists the dotted candidates instead; pass the dotted one. The answer is for
the version installed where the command runs, which is the version the code
will run against.
Stability. Every entry is one of three:
--list leaves them out.Where geoML is not installed, the same descriptions are on the reference pages of the documentation site, https://italo-goncalves.github.io/geoML/reference/.
Install:
pip install git+https://github.com/italo-goncalves/geoML
Backend: TensorFlow 2.x + TensorFlow-Probability, GPU-accelerated. All
computation is in float64: geostatistical matrices are ill-conditioned and
float32 breaks the Cholesky factorizations. One exception: where
TensorFlow sees a GPU, the large elementwise arrays of the quadrature a GP
node takes over an uncertain input run in float32
(GPOptions(quadrature_precision=None), the default), every product and sum
after them in float64 -- held-out scores unchanged, results moving in
about the eighth digit against a CPU run -- and so do the realizations'
random-feature products, which on a GPU's default TensorFloat-32 cores
move a realization by up to about a percent and with the batch it is
computed in; pass "float64" to keep one precision everywhere. Realizations are stored as float32 (half the disk,
every read widened back to float64); geoml.set_realization_dtype("float64")
keeps them wide.
License: GPL-3 (dual-licensed; see README). Version: 0.10.10.
Layout: five subpackages (data, latent, math, stats, viz) plus
the older plots, around modules left flat on purpose: models,
likelihood, kernels, transform, warping, parameter, datasets,
metrics, persistence, storage. A saved model records the dotted path
of every class in it and imports it by that path when it loads, which is
why those modules never move.
PointData, the grids
(Grid1D/Grid2D/Grid3D), the variable-size block model BlockSet3D,
and triangulated meshes (Surface3D, Solid3D). A container holds
variables (continuous, vector, compositional, categorical), and each
variable holds columns: measurements, a prediction, variances,
quantiles, realizations.container.values("V/prediction") is a numpy array,
container.get("V/quantiles/0.5") the column itself (for as_image() or
get_contour()), container.tree() the picture of what is there.
_metadata/... holds per-location facts the model never reads: hole ids,
depths, folds, filters. Paths are in references/notebook-style.md §0.models.VGPNetwork is the core. The network is built from latent nodes:
an input node carrying the inducing points, GP nodes, and operations that
combine them. Its leaves are where the likelihoods attach: pass one
leaf per likelihood, or name them together with
variables={"Rock": likelihood, ...}. A likelihood carries a warping,
the monotone map from the data to the Gaussian scale the model works on.model.predict(grid) fills the grid's columns. grid.unpredicted() names
what no prediction reached yet, so a cancelled or partial prediction is
finished with model.predict(grid, where=grid.unpredicted()).
grid.clear_predictions(where=...) empties what was predicted at some
locations and keeps the measurements; grid.drop(name) removes a
variable whole.with geoml.progress(callback): training, prediction, refinement,
cross-validation and mesh sets report each unit they finish; the callback
raising cancels the call. A refinement's events carry what each pass cut
in detail.Parametric holding RealParameters,
constrained through their transforms and trained by Adam. Bounds a
constructor clips to are in the catalogue.import geoml
import geoml.latent as gl, geoml.transform as tr
import geoml.kernels as kr, geoml.likelihood as lk
geoml.set_seed(1234) # BEFORE constructing anything
jura_train, _ = geoml.datasets.jura()
labels = list(jura_train.get("Landuse").labels)
network_input = gl.BasicInput(
inducing_points=jura_train, transform=tr.Isotropic(0.5))
network_output = gl.BasicGP(
parent=network_input, size=len(labels), kernel=kr.Matern32(),
fix_range=True)
model = geoml.models.VGPNetwork(
data=jura_train, variables="Landuse", latent_network=network_output,
likelihoods=lk.CategoricalGaussianIndicator(n_components=len(labels)),
options=geoml.models.GPOptions(verbose=False))
model.train_full(5)
grid = geoml.data.Grid2D(start=[0, 0], end=[6, 6], n=[21, 21])
model.predict(grid) # writes into the container
image = grid.get("Landuse/predicted").as_image()
model.to_dot() renders the network as a diagram. The full modelling arcs
are the case-study chapters: Walker Lake (15), Jura with a non-stationary
multivariate network (16), and a folded vein in section, stationary
against GPWalk (17).
| Module | For |
|---|---|
data | the containers and variables, meshes, block models, drillholes (DrillholeData, converted to points and never fed to a model), Zarr storage, and data.inducing for building inducing points |
latent | the nodes a network is built from |
likelihood, warping | the observation model and the map to the Gaussian scale |
kernels, transform | covariance functions, and the transforms of the input they read (anisotropy, projections, faults) |
models | VGPNetwork, GPOptions, and the workflows as free functions: refine, cross_validate, search_throw |
metrics, plots | scores, and figures in two backends (Explorer for print, Interactive for plotly) |
datasets | the bundled data (§3) |
python -m geoml.catalogue --list CATEGORY gives the classes of each.
What was measured to work, as of this version. Arguments for each class are in the catalogue.
BoxCox then ZScore; where the
data hold zeros, pass BoxCox(..., shift=None), which sets each column's
shift to its smallest positive value at initialize -- the default
millionth sinks the zeros far down the logarithm and steepens the
inverse. A variable centred on zero:
YeoJohnson then ZScore. A vector of grades: BoxCox, RobustPCA,
ZScore, SinhArcsinh, ZScore, chained with ChainedWarping. These
parametric links replaced Spline, which stays for saved models (with
backbone="rq" if you use it anyway). One marginal transform is where
the benefit stops: stacking rotation-and-spline pairs made held-out
scores worse. A model with a RobustPCA saved before 0.10.7 reopens
with other axes than it trained with (it warns): refit and save it again.Laplace, EpsilonInsensitive)
pushed back through the link can have an unbounded variance in data units
and over-wide intervals, though its bound may look better. initialize
warns where that is the case and names the noise rate below which the
mean or the variance has no finite value; a Student's t there has none. For data with
gross errors, likelihood.Mixture (experimental) names the bad readings,
with its warping led by ZScore(robust=True).likelihood.LikelihoodMixture over continuous likelihoods, each with its
own warping. With shares="latent" the shares change from place to place:
read them from a GP node of their own, apart from the populations', and
where a domain was logged let a CategoricalGaussianIndicator with
bias=True, trained on every logged interval rather than the assayed ones
alone, read the same node. On one deposit it beat a single likelihood on
every metal out of fold, but its intervals came out narrower than the
held-out data supported; check them.data.inducing.experts over
data.inducing.combine. Where the survey does not fill its box -- a fan
of drillholes -- take the backbone from data.inducing.from_hull, which
keeps the lattice inside the data's hull and a margin around it.
data.inducing.from_cover_tree places points no closer than a given
separation (with transform= for anisotropy), the guarantee of
numerically stable sparse GPs; whether it scores better than k-means at
equal counts is not yet measured. A rough kernel (exponential,
spherical, Matérn 3/2) needs inducing points close to every location the
model will be asked about -- a lattice as fine as the data, the data's own
locations among the points: elsewhere the variance the points cannot
reach, 1 - k K⁻¹ kᵀ, stays in the prediction and the realizations, and
on a 10-unit lattice over Walker Lake it was two-thirds of the reported
variance at the samples, the intervals hedging and the variogram fan well
above the data. Experts
come out compact and share points with every neighbour once each borrows
at least as many points as it has neighbours: keep experts large enough
for their overlap (an overlap of 0.1 on 25-point experts cannot reach six
neighbours). How many points a model can absorb depends on the whole
configuration; measure it on held-out data rather than carrying a number
across problems.Linear off the first's
field, added to the second's GP through LinearCombination, with
unit_norm=False so the model can decline the influence. A field that is
not stationary: GPWalk moves the coordinates and a stationary kernel
reads the moved space. Build the GP reading the walk with
isotropic=True: a range per direction there is a second description
of the anisotropy, which belongs in the input's transform. Left to
train, the walk's strength stays short under the joint rule and bends
the space without folding it; reach= holds it (half a transformed unit
folded a drilled vein the way the releases before 0.9.0 did, a full unit
tore it into pieces), so choose it on held-out data. A walk's
memory grows with its steps and with the square of the points per
expert; where train_by_expert still runs out of device memory,
coverage below its default computes fewer experts a batch.
Independent parts of a model can sit on
independent trees, one leaf each. Chapter 16 builds the first two, one
leaf per variable.GPOptions(propagation="joint"), the default); a
model saved before keeps the old rule, which made deep networks
overconfident (propagation="marginal"). Build a deep network with the
coordinates concatenated beside the inner GP (Concatenate(root, inner)). A GP on an uncertain input takes the Gaussian, exponential,
Matérn or rational quadratic kernel; spherical and cubic are refused
there, and the error message says so. Since 0.10.0 a GP node whose own
inducing points are uncertain -- a deep layer, a walk's reader -- takes
its variance in closed form (GPOptions(deep_moments="hinge"), the
default; "blur" and "bound" the other closed forms, "quadrature" what
a save made before keeps). Give such a node the Gaussian kernel: it is
one component where a Matérn or the exponential is eight, a step nearly
three times faster under the hinge, and under "bound" the others are
slower than the quadrature by far (the model warns). Since 0.9.4 the
realizations carry the variance the prediction reports
(GPOptions(full_variance=True), the default for a new model): a GP
reading an uncertain input takes its
second moment with its own inducing inputs uncertain too and draws
through its parent's realizations, and every GP node's realizations carry
what its inducing points leave out, shallow models included -- except a
spherical or cubic node, whose kernel has no random-feature form: it
carries the explained part only, and the model warns. A model
saved before keeps 0.9.3's realizations, which held only the explained
part -- a third to three fifths of a deep model's variance. On a
GaussianInput a BasicGP takes the mixture's moments (the variance of
the mean over the input included); UncertainInputGP is deprecated. A
location error is still better
left untold: a noise term absorbs it. That variance costs time and
memory in proportion to the inducing points; experts do not shorten it,
train_by_expert holds a fraction of it in memory.GPOptions(training_tolerance=0.01) stops once the bound
has settled; the last few percent of the bound buys sharpness held-out
data does not support.model.train_by_expert, model.predict_by_expert,
refine(..., by_expert=True) for a block model, and by_expert=True on
predict_measurements and predict_node (cross_validate(method= "by_expert") draws its measurements so too); a prediction's
batches are sized to the device for the experts it computes at once --
on a GPU measured on its first batches, each group's -- so
prediction_batch_size is a cap, not a size to tune. It matched or beat
train_svi on CRPS and on a deposit's rock types in a third to a half of
the device memory, a little behind on rmse on a smooth synthetic field.
Fewer, larger experts scored better than many small ones at a fixed
total of inducing points. A deep GP fed by another needs the coordinates
concatenated into its input to stay local; one fed by a GP alone spreads
every expert over the field. Five nodes are refused; the message names
them.GPOptions(expert_weights=None)): a GP reading an uncertain
input (a GP on a GP, a walk's reader) then predicts each group of
locations with its own experts only -- five times faster at half the
memory on a GeoScape walk network -- and it scored better held out on a
deposit's rock types (20 experts) and on the folded vein's walk, but 4-7%
worse rmse on two small shallow sets whose kernel range is long against
the experts, where expert_weights="variance" (each expert weighted by
its own posterior, the rule before 0.10.6) is worth comparing on held-out
data. expert_temperature and expert_blend="balanced" exist and helped
nowhere consistently.PointData.spatial_k_fold writes folds that resemble the
real prediction task, models.cross_validate scores the model out of
fold, and models.conformalize recalibrates the intervals.
models.score_measurements gives the same scores for a model's draws at
any measured container -- a validation set, or the training data. In-sample
scores flatter; only out-of-fold ones speak for the ground between samples.BlockSet3D refined by models.refine: predict
coarse, split only the blocks the prediction's surface runs through and
whose realizations agree on it -- their coherence, at least 0.2 and
above the noise floor (a block the model is merely unsure about is left
whole, however its mean wobbles across a cut-off) -- predict what the
split made. MeshSet contours a column for the prediction and every
realization at once, with volumes measured as it goes; a limit given as
(other_set, key) cuts each realization by that set's body of the same
realization. A set built with store= and stopped is finished with
MeshSet.resume(store, blocks), which keeps what was made.The papers and the code name the same things differently.
| Paper concept | In the code |
|---|---|
| Inducing points $\mathbf{T}$, $\mathbf{u}$ | the container given to BasicInput(inducing_points=…), read by the GP nodes above it |
| DGP uncertainty propagation | each node hands on a mean, a variance and its covariance with the inducing points; there is no separate class |
| Expected kernel | inside the GP nodes, under GPOptions(propagation="joint") |
| Paciorek kernel | the propagation before 0.9.0, kept for older saves as propagation="marginal" |
| SDE node | latent.GPWalk |
| Local experts | overlapping inducing sets from data.inducing.experts |
| CLR transform | warping.CenteredLogRatio |
| PCA after CLR | warping.PCA / warping.RobustPCA |
| ε-insensitive likelihood | likelihood.EpsilonInsensitive |
| Boundary / contact likelihood | likelihood.CategoricalGaussianIndicator and its hierarchical twin |
| Structural / dip-strike field | latent.GradientConstrainedInput with directional data |
| Warped GP | a warping chain on the likelihood (§1.4) |
| Multivariate weight matrix $\mathbf{M}$ | latent.LinearCombination |
geoml.set_seed(seed) before constructing
anything. It is the only knob: parameter initialization and a model's
simulation stream both draw from it, and a saved model keeps its seed.
cross_validate draws each fold's fresh variational state from the same
generator, so two runs in a row differ; set the seed right before each
run that must repeat. Predictions are compiled with XLA for a new model
(jit_predict, falling back where XLA refuses); compiled and plain agree
to rounding, realizations included. A model that trains on realizations
(a non-Gaussian leaf, a mixing warping) draws them afresh every step
(fresh_training_draws, the
default for a new model): its training log is a noisy estimate of the
bound, still exactly repeatable, and a model saved before 0.9.3 keeps
the fixed draws it was trained with.bias=False): away from
its data a field returns to zero, so an indicator connects its samples
where a trained constant let it ring each with a blob. A categorical
likelihood's class prior belongs on the likelihood:
CategoricalGaussianIndicator(bias=True) gives the majority category the
ground away from the data. bias=True on a GP node trains a constant per
expert and output, for a field whose level carries meaning. A model saved
before keeps its trained bias.values() for what you compute with, get() for what you draw.
Never values() a bare simulations path: it reads every realization
into memory at once, fatal on a block model. Read one realization
("V/simulations/7") or reduce in row bands.mode="r". A container's open
defaults to "r+", and a prediction into it writes into the store.
Read-only, a write is refused and the store stays as it was; to_zarr
never writes over the store a container reads from.model.predict_measurements, not the stored realizations -- and
simulation_pairs draws the stored ones, so even a perfect model shows
them narrower than the measured half.model.predict_node, into
a LatentVariable on the latent scale: what a GPWalk did to the
coordinates, what a trend adds. Points only, never a block model; its
realizations match the leaf's through operation nodes, not across a GP.cross_validate swaps data into one model for that reason; do the same.import geoml.latent as gl); package source
uses underscore-prefixed ones. Never mix the two.geoml.datasets bundles walker(), jura(), ararangua(), andrade(),
arctic_lake(), example_fold() and sunspot_number() (which downloads
from sidc.be). macpass(path) reads a drillhole database the user
downloads themselves. The research line also used data that are not
bundled: the Passo Feio dip/strike data, a quartz-vein drillhole set, the
Zhang gold data and the Thalanga VHMS assays.
references/manual/ holds the manual's chapters, copied at each release
from the repository, where every code block in them is run. Read the one a
task touches before writing code for it; the case studies are the complete
arcs.
| Chapter | Covers |
|---|---|
01-why-another-geostatistics.md | what the approach offers over kriging |
02-the-gp-is-kriging.md | the GP posterior as kriging |
03-inducing-points-and-the-elbo.md | inducing points, experts, the bound |
04-warpings-likelihoods-and-the-gaussian.md | warpings and likelihoods |
05-latent-networks.md | building networks, deep models |
06-categories-and-boundaries.md | categorical variables and contacts |
07-simulation.md | realizations and derived variables |
08-change-of-support.md | blocks and support |
09-from-database-to-data.md | drillhole databases to point data |
10-containers-and-addressing.md | containers and tree paths |
11-building-and-training.md | constructing and training a model |
12-prediction-blocks-and-surfaces.md | predicting into grids, blocks and meshes |
13-validation.md | folds, cross-validation, calibration |
14-reporting.md | grade-tonnage, swaths, figures |
15-case-study-walker-lake.md | a positive grade in 2D |
16-case-study-jura.md | a non-stationary multivariate model with rock types |
17-case-study-folded-vein.md | a folded vein in section, stationary against a walked input |
Figure links point at the documentation site. Chapter 17 reads its truth, a
small raster, from docs/manual/data/ in the repository.
references/manual/01-why-another-geostatistics.md (opens in a new tab)references/manual/02-the-gp-is-kriging.md (opens in a new tab)references/manual/03-inducing-points-and-the-elbo.md (opens in a new tab)references/manual/04-warpings-likelihoods-and-the-gaussian.md (opens in a new tab)references/manual/05-latent-networks.md (opens in a new tab)references/manual/06-categories-and-boundaries.md (opens in a new tab)references/manual/07-simulation.md (opens in a new tab)references/manual/08-change-of-support.md (opens in a new tab)references/manual/09-from-database-to-data.md (opens in a new tab)references/manual/10-containers-and-addressing.md (opens in a new tab)references/manual/11-building-and-training.md (opens in a new tab)references/manual/12-prediction-blocks-and-surfaces.md (opens in a new tab)references/manual/13-validation.md (opens in a new tab)references/manual/14-reporting.md (opens in a new tab)references/manual/15-case-study-walker-lake.md (opens in a new tab)references/manual/16-case-study-jura.md (opens in a new tab)references/manual/17-case-study-folded-vein.md (opens in a new tab)references/manual/README.md (opens in a new tab)references/notebook-style.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub italo-goncalves/geoml --plugin geomlOther plugins' skills for the same job