Predict outcomes

Examples use import kernelmix as km. See the tutorial for a complete analysis.

Prediction

fit.predict_h(Znew=None, *, probability=0.95, max_draws=None, seed=None)
fit.predict(
    Znew=None, Xnew=None, *, kind="mean", scale="response",
    probability=0.95, max_draws=None, seed=None, offset=None, cluster_new=None,
)
fit.posterior_moments_h(Znew=None, max_draws=None)

Supply exposures in original units and training column order; named columns must match. Prediction reuses training standardization. New profiles require Xnew when adjustments were fitted, without the added intercept. Omitting new data uses retained training rows.

Call Quantity
predict_h Joint draws of h, excluding linear adjustment and all random effects.
predict(..., kind="mean", scale="response") Gaussian/count means, binary probabilities, or survival relative hazards.
predict(..., kind="observation", scale="response") Gaussian, binary or count future observations; survival is unsupported.
predict(..., kind="mean", scale="latent") h plus linear adjustment and requested random effects, before link transformation; count offsets are included. Correlated Gaussian means also condition on training residuals.
predict(..., kind="observation", scale="latent") Gaussian outcomes or binary latent outcomes including residual noise; binary residual variance is one. Count/survival latent observation draws are unsupported.
posterior_moments_h Dictionary with deterministic integrated mean and covariance for h, averaging conditional moments over saved draws.

max_draws selects evenly spaced states per chain (at least two), without refitting. seed controls prediction draws. A Prediction stores draws shaped (chains, selected_draws, rows), mean, sd, lower, upper, joint covariance, probability, scale and kind. to_records() gives one summary per row. Intervals are equal-tailed and pointwise: each describes uncertainty for one row, rather than for all rows at once. Observation intervals also include new outcome variation.