aquakin.CalibrationResult#

class aquakin.CalibrationResult(params, params_named, loss, converged, message, n_iter, parameter_names, transforms, posterior_cov=None, posterior_std_unconstrained=None, params_named_std=None, hessian_unconstrained=None, priors_applied=<factory>, C0_fitted=None, ic_named=None)[source]#

Bases: object

Result of calibrate().

Variables:
  • params (jnp.ndarray) – Full parameter vector after optimisation (fixed entries unchanged).

  • params_named (dict[str, float]) – Free parameters by namespaced name, in physical space.

  • loss (float) – The full scalar objective at the MAP: the summed data loss plus any prior penalty. It is the same value regardless of optimizer — for loss="nll" it is the complete Gaussian negative log-likelihood (including the sum(log(sigma)) normaliser), not the Gauss-Newton 0.5*||residual||^2 (which drops that constant).

  • converged (bool) – Whether SciPy declared convergence.

  • message (str) – Optimiser status message.

  • n_iter (int) – Optimiser iteration count: nit for the L-BFGS-B optimiser, and the Jacobian-evaluation count (njev, ~one per trust-region iteration) for the Gauss-Newton least-squares optimiser, which exposes no direct iteration count. Either way it is an iteration-scale figure, not the raw residual/function-evaluation count.

  • parameter_names (list[str]) – Ordered free-parameter names. Matches the rows / cols of posterior_cov and hessian_unconstrained when present.

  • transforms (list[str]) – Transform used for each free parameter, in the same order.

  • posterior_cov (jnp.ndarray, optional) – (d, d) covariance matrix in unconstrained space (Laplace). None if laplace=False was passed.

  • posterior_std_unconstrained (jnp.ndarray, optional) – Marginal std devs in unconstrained space.

  • params_named_std (dict[str, float], optional) – Marginal std devs propagated back to physical space via the delta method (|dp/dtheta| * std_unconstrained).

  • hessian_unconstrained (jnp.ndarray, optional) – Raw FD Hessian of the loss at the MAP, unconstrained-space.

  • priors_applied (dict[str, tuple[float, float]], optional) – Gaussian priors (physical-space (mean, std)) that were added to the objective, by free-parameter name. Empty if no priors were active.

  • C0_fitted (list[jnp.ndarray], optional) – When free_ic is used, the fitted initial-state vector for each dataset (full species vectors, free pools set to their fitted values). None if no initial conditions were fit.

  • ic_named (list[dict[str, float]], optional) – When free_ic is used, the fitted free initial pools per dataset, by species name. None if no initial conditions were fit.

Parameters:
  • params (Array)

  • params_named (dict[str, float])

  • loss (float)

  • converged (bool)

  • message (str)

  • n_iter (int)

  • parameter_names (list[str])

  • transforms (list[str])

  • posterior_cov (Array | None)

  • posterior_std_unconstrained (Array | None)

  • params_named_std (dict[str, float] | None)

  • hessian_unconstrained (Array | None)

  • priors_applied (dict[str, tuple[float, float]])

  • C0_fitted (list | None)

  • ic_named (list | None)

__init__(params, params_named, loss, converged, message, n_iter, parameter_names, transforms, posterior_cov=None, posterior_std_unconstrained=None, params_named_std=None, hessian_unconstrained=None, priors_applied=<factory>, C0_fitted=None, ic_named=None)#
Parameters:
  • params (Array)

  • params_named (dict[str, float])

  • loss (float)

  • converged (bool)

  • message (str)

  • n_iter (int)

  • parameter_names (list[str])

  • transforms (list[str])

  • posterior_cov (Array | None)

  • posterior_std_unconstrained (Array | None)

  • params_named_std (dict[str, float] | None)

  • hessian_unconstrained (Array | None)

  • priors_applied (dict[str, tuple[float, float]])

  • C0_fitted (list | None)

  • ic_named (list | None)

Return type:

None

Methods

__init__(params, params_named, loss, ...[, ...])

predictive_band(reactor, C0, t_eval, *[, ...])

Posterior-predictive band by propagating Laplace draws through a solve.

Attributes

C0_fitted

hessian_unconstrained

ic_named

params_named_std

posterior_cov

posterior_std_unconstrained

params

params_named

loss

converged

message

n_iter

parameter_names

transforms

priors_applied

predictive_band(reactor, C0, t_eval, *, n_draw=200, percentiles=(2.5, 97.5), seed=0, eig_keep=None, observed_species=None)[source]#

Posterior-predictive band by propagating Laplace draws through a solve.

Samples the calibrated parameters from the Laplace posterior N(MAP, posterior_cov), inverse-transforms each draw to physical space, sets it into the fitted parameter vector, integrates reactor from C0 over t_eval, and returns the pointwise percentile envelope across draws. The draws are taken from self.posterior_cov — the same eigen-truncated covariance behind params_named_std — so the band and the reported marginal std devs regularise identically. The non-identifiable directions were already dropped (at calibrate time, via laplace_eig_keep), so they carry zero variance and the draws stay finite.

Requires that the calibration was run with laplace=True (so a Hessian is available). The supplied C0 may differ from the calibration initial state — e.g. propagate the calibrated-rate uncertainty through a held-out / validation batch.

Parameters:
  • reactor (Reactor) – Reactor to integrate (forward solves only; any adjoint is fine).

  • C0 (jnp.ndarray) – Initial state to propagate.

  • t_eval (jnp.ndarray) – Output times; the band is reported at these points.

  • n_draw (int) – Number of posterior draws.

  • percentiles (tuple[float, float]) – Lower / upper band percentiles (default the central 95%).

  • seed (int) – Seed for the draws (reproducible).

  • eig_keep (float, optional) – Deprecated and ignored. The identifiable-subspace truncation is now applied once, at calibrate time, via calibrate(laplace=LaplaceConfig(eig_keep=...)), so the band and params_named_std share one regulariser. Passing a value here emits a DeprecationWarning.

  • observed_species (list[str], optional) – Restrict the returned band to these species. None returns all.

Return type:

PredictiveBand