Skip to content

ExternalDriftKriging

ExternalDriftKriging(
    variogram: Variogram,
    search: Search | Sequence[Search],
    drift: str | Sequence[str],
    *,
    degree: int = 0,
)

Kriging with a polynomial drift of degree (0 by default) plus one column per external drift variable, evaluated at the samples with fit and at the targets with predict.

unit property

unit

Unit of the estimates: that of the fitted values, ratio for probabilities; None if unknown.

cross_validate

cross_validate(
    *, folds: int | None = None
) -> CrossValidation

Re-estimates every sample from the others, through the same search passes.

Parameters:

Name Type Description Default
folds int

Leave-one-out when None; otherwise k-fold, each sample estimated without the samples of its fold. Samples fitted with holes keep their holes whole: the j-th of the sorted hole ids goes to fold j % folds. An untagged sample i goes to fold i % folds, so without holes and with folds equal to the number of samples this is leave-one-out. Folds span all domains; each held-out sample is estimated in its own domain.

None

fit

fit(
    coords,
    values,
    *,
    holes=None,
    error_variance=None,
    domains=None,
    domain_column=None,
)

Stores the samples. Samples sharing a location keep the first one, with a warning naming their holes.

Parameters:

Name Type Description Default
coords (array_like, PointSet or BlockModel)

Sample locations, (n, 2) or (n, 3), or a container whose columns values, holes, error_variance and domain_column may name.

required
values array_like or str

Sample values, or their column in coords; their unit, if any, becomes the unit of the estimates.

required
holes array_like or str

Drill-hole ids or names, for max_per_hole and the n_holes diagnostic.

None
error_variance array_like or str

Variance of each sample's measurement error, for data of different quality (kriging only). It is added to the sample's diagonal entry in the kriging system, so the estimate no longer honors a noisy value and leans towards its neighbors. Cokriging, disjunctive kriging and the simulators do not take it.

None
domains array_like

Domain label of each sample: strings, numbers or booleans. A target is then estimated from the samples of its own domain, plus those of other domains within Search soft. Samples sharing a location are dropped within a domain only; where a search reaches several at one location, it uses the one of the target's domain, or else the first. predict then needs domains too.

None
domain_column str

The column of coords holding the domains; instead of domains.

None

from_parquet classmethod

from_parquet(path)

Reads to_parquet output; predictions match the saved estimator's bit for bit.

Parameters:

Name Type Description Default
path str or PathLike
required

Raises:

Type Description
InvalidInput

If the file holds another class or a newer format.

predict

predict(
    targets,
    *,
    return_variance: bool = False,
    anisotropy=None,
    diagnostics: bool = False,
    domains=None,
    domain_column=None,
)

Estimates at targets; NaN where the search found too few samples.

Parameters:

Name Type Description Default
targets (array_like, PointSet or BlockModel)
required
return_variance bool

Also return the kriging variance.

False
anisotropy LocalAnisotropy

Orients each target's variogram and search.

None
diagnostics bool

Return a Table instead: value, variance, efficiency (kriging efficiency), slope (slope of regression), n_samples, pass (the search, from 1, that filled each target), n_holes (distinct holes among the samples used; untagged samples count one each), mean_distance (to the samples used), negative_weight_sum, lagrange (the Lagrange multiplier; 0 for simple kriging, NaN where undefined), max_samples_reached (1 where the search returned max_samples), n_other_domain (samples used from domains other than the target's), support_variance (the variance of the target's support, the sill for points and sill minus the mean variogram within the block for blocks, nugget excluded), estimate_variance (the variance of the estimator; the further below support_variance, the smoother the estimates) and target_met (1 where the samples used reach the search's target_slope or target_efficiency, 0 where even max_samples fall short, NaN without one). NaN where unestimated.

False
domains array_like or label

Domain label of each target, or one label for all of them; required when fitted with domains. Targets of a domain without samples stay NaN.

None
domain_column str

The column of targets holding their domains; instead of domains.

None

Returns:

Type Description
ndarray, tuple of ndarray or Table

Estimates in unit, variances in its square.

to_parquet

to_parquet(path) -> None

Writes the samples as Parquet columns and the parameters as JSON in the file metadata.

Parameters:

Name Type Description Default
path str or PathLike
required
with_search(search: Search | Sequence[Search])

A copy of the estimator, fitted samples included, with search in place of its searches.

Parameters:

Name Type Description Default
search Search or sequence of Search

One search, or passes: targets one leaves unestimated go to the next.

required

used in