Skip to content

GaussianImputer

Imputes missing variables from the variables present in the same sample and, with spatial, from nearby samples.

Each variable is normal-scored on its observed values; the mean and covariance of the scores are fitted by expectation-maximization, missing entries included. Each missing score is drawn from its Gaussian distribution given the scores present in its row and back-transformed, so the imputed values keep the histograms and correlations of the data.

With spatial, the scores follow an intrinsic model: every variable and pair of variables shares the correlogram of spatial, scaled by the score covariance (of the row's component, with a mixture). Rows are visited along a random path and their missing scores drawn by simple cokriging from the scores in the row and in the nearest samples, imputed ones included.

Parameters:

Name Type Description Default
components int or None

Gaussians mixed in the scores, e.g. 2 for two mineral associations that one Gaussian cannot represent; None picks 1 to 6 by BIC. A missing score is then drawn from a component picked by its probability given the scores present in the row.

1
seed int

Seed of the mixture and of the draws; the same seed imputes the same values.

0
spatial Variogram

Normal-score variogram shared by all variables; its sill is rescaled to one. A pure nugget imputes as without spatial.

required
neighbors int

Nearest samples, in the variogram's anisotropic distance, that each draw conditions on; those beyond the range are left out.

16

correlation_ property

correlation_

Correlation matrix of the normal scores.

fit method descriptor

fit(data, *, coords=None, weights=None)

Fits the normal scores and their covariance.

Parameters:

Name Type Description Default
data (array_like, shape(n, variables))

NaN marks a missing variable; each variable needs two values.

required
coords array_like, shape (n, 2) or (n, 3), or PointSet

Sample locations, needed with spatial; transform uses them when given none.

None
weights array_like

Declustering weights, for the scores and the covariance.

None

from_json staticmethod

from_json(text)

Reads to_json output; raises InvalidInput on another class's JSON or a newer format.

to_json method descriptor

to_json()

JSON of the parameters and, once fitted, the fitted state.

transform method descriptor

transform(data, *, coords=None)

data with every NaN replaced by an imputed value; the other values are returned unchanged.

Parameters:

Name Type Description Default
data (array_like, shape(n, variables))
required
coords array_like, shape (n, 2) or (n, 3), or PointSet

Locations of data, used with spatial; defaults to those given to fit.

None

used in