krigekit.variogram_system_indicator#
Indicator variogram system: categorical encoding, closure-aware LMC fitting.
An IndicatorVariogramSystem is a VariogramSystem specialised
for mutually exclusive, exhaustive categorical indicators I_1 + ... + I_K = 1.
It owns the construction of indicator variograms in Python – encoding raw
categories into K binary variables, building the K x K coregionalization
from category proportions, and fitting a coregionalization that is both positive
semidefinite and closed (rows summing to zero). The Fortran IndicatorKriging
wrapper still executes the kriging and post-processes probabilities; this system
configures it via apply().
Classes#
Variogram system for |
Functions#
|
Return the |
|
Return the closed zero-lag indicator covariance |
|
Return an orthonormal |
Module Contents#
- krigekit.variogram_system_indicator.encode_indicator_matrix(values, categories)#
Return the
(nobs, K)one-hot indicator matrix for rawvalues.categoriesis the ordered list ofKlabels; columnkis the binary indicatorvalues == categories[k]as floats.
- krigekit.variogram_system_indicator.indicator_covariance(proportions)#
Return the closed zero-lag indicator covariance
diag(p) - p p^T.For a probability vector
psumming to one this is positive semidefinite with row sums of zero, giving auto variancesp_k (1 - p_k)and cross covariances-p_k p_l.
- krigekit.variogram_system_indicator.contrast_basis(ncat)#
Return an orthonormal
(K, K-1)basisQof the contrast space.Columns of
Qare orthonormal and orthogonal to the all-ones vector, soB = Q L L^T Q^Tis positive semidefinite and closed (B 1 = 0) for any lower-triangularL.
- class krigekit.variogram_system_indicator.IndicatorVariogramSystem(categories=None, ncat=None)#
Bases:
krigekit.variogram_system.VariogramSystemVariogram system for
Kmutually exclusive categorical indicators.Create an indicator system from category labels or a count.
Provide
categories(an ordered label list) orncat. The system has exactlyKvariables (ivar = 1..K); secondary co-variates are out of scope here – configure those on the kriging object directly.- property ncat#
Number of categories
K(always the system’s variable count).
- encode_indicators(categories)#
Return the one-hot indicator matrix for
categoriesusing labels.
- set_categorical_obs(coord, categories, *, category_labels=None, variance=None)#
Encode raw categories into
Kindicator datasets and store them.category_labels(or the constructorcategories) fixes the label order; otherwise sorted unique values are used. Proportions are computed from the encoded indicators.
- calc_proportions()#
Compute and store category proportions from configured indicators.
- initial_indicator_covariance()#
Return the closed zero-lag covariance
diag(p) - p p^T.
- set_indicator_vgm(vtype='sph', nugget=0.0, sill=1.0, a_major=1.0, a_minor1=None, a_minor2=None, azimuth=0.0, dip=0.0, plunge=0.0, sill_strategy='theoretical', cross_strategy='closure', proportions=None)#
Configure all
K^2indicator pairs with one shared model shape.sill_strategysets the auto (diagonal) partial sills:"theoretical"–p_k (1 - p_k)from category proportions;"uniform"– the givensillfor every category.
cross_strategysets the off-diagonal partial sills:"closure"(recommended) –-p_k p_l, the closed indicator covariance off-diagonal;"independent"– zero (no co-kriging);"proportional"–sqrt(s_k s_l)from the auto sills;"uniform"– the givensill.
Legacy configurations map directly: old
cross="same"issill_strategy="uniform", cross_strategy="uniform"; oldcross="independent"/"proportional"pair withsill_strategy="theoretical".
- fit_indicator_lmc(pairs=None, shared_ranges=True, x_col=('distance', 'mean'), y_col=('variogram', 'mean'), sigma_col=None, weight_col=None, fit_nugget=True, inplace=False, raw_kwargs=None, avg_kwargs=None, max_nfev=20000, **kwargs)#
Fit a closed, PSD linear model of coregionalization for indicators.
Each nested coregionalization matrix is parameterized as
B = Q L L^T Q^TwithQthe contrast basis, guaranteeing positive semidefiniteness and closure (B 1 = 0) at every fitted lag. Ranges are shared across pairs whenshared_ranges=True. Returns aFitResultwhosetargetis the fitted indicator system.
- validate_closure(tol=1e-06, include_nugget=True)#
Check that every fitted coregionalization matrix is closed.
Raises if any matrix (sill structures, plus the nugget when
include_nugget) has a row sum exceedingtolin magnitude.
- fit(*, method='closure', **kwargs)#
Fit the indicator system;
method="closure"is the default."closure"runsfit_indicator_lmc();"lmc"and"pair"fall through to the unconstrainedVariogramSystemfacade.
- apply(kriging, observations=True, variograms=True, replace=True, pairs=None)#
Transfer indicators and structures, checking
ncatagreement.