gpridge.surrogate ================= .. py:module:: gpridge.surrogate .. autoapi-nested-parse:: Layered-chain configuration for the GP surrogate. ``Surrogate`` is an immutable fluent builder describing which arm of the layered chain (MAP / +PSIS-Laplace / +INLA-Delta / +RFF) the underlying GP uses. Compose it with ``.delta()``, ``.rff(D)``, ``.psis()`` and ``.with_hyperparameter_mode('inla')``. Pass the result to :class:`~gpridge.gp.GaussianProcess` as ``surrogate=``. Example:: Surrogate.map() Surrogate.map().hssvd() Surrogate.laplace_slice() Surrogate.laplace_slice().delta() Surrogate.laplace_slice().delta().rff(512) Classes ------- .. autoapisummary:: gpridge.surrogate.Surrogate Module Contents --------------- .. py:class:: Surrogate Immutable, hashable layered-chain config. Build one with :meth:`map` or :meth:`laplace_slice` and refine it with the chain modifiers, each of which returns a new object. The fields below are the stored settings. .. py:attribute:: uncertainty_mode :type: str :value: 'map' Posterior arm, one of ``"map"``, ``"bma"``, ``"laplace"``, ``"laplace-slice"``, ``"eb"`` or ``"svgd"``. The factories set it. .. py:attribute:: use_psis_laplace :type: bool :value: False Apply Pareto-smoothed importance sampling to the Laplace slice. .. py:attribute:: use_psis_deterministic :type: bool :value: True Use the deterministic grid for the PSIS draw. .. py:attribute:: use_delta_method :type: bool :value: False Add the alpha-K Hessian Laplace variance correction. .. py:attribute:: delta_uh_min_diag :type: float :value: 1e-06 Conditioning gate of the delta correction. The correction is switched off when ``min(diag(U_H))`` falls below this value. Zero or negative disables the gate. The default matches the C++ side. .. py:attribute:: delta_max_ratio :type: float :value: 100.0 Cap of the per-query delta variance as a multiple of the signal variance. Zero or negative disables the cap. The default matches the C++ side. .. py:attribute:: rff_features :type: int :value: 0 Number of random Fourier features. 0 keeps the exact kernel and -1 selects the count against held-out data (``"auto"``). .. py:attribute:: rff_force_tol_fraction :type: float :value: 0.0 Share of the force tolerance that the automatic selection may spend. 0 derives the share from the gradient noise. Used only when ``rff_features`` is -1. .. py:attribute:: hyperparameter_mode :type: str :value: 'scg' Hyperparameter optimiser, ``"scg"`` (scaled conjugate gradient) or ``"inla"``. .. py:attribute:: use_hssvd_backend :type: bool :value: False Use the HS-SVD stable-basis solver path. .. py:attribute:: disable_output_normalization :type: bool :value: False Skip the output normalisation of the training energies. .. py:method:: map() -> Surrogate :classmethod: Maximum a posteriori fit, the default surrogate. .. py:method:: laplace_slice(*, deterministic: bool = True) -> Surrogate :classmethod: Laplace-slice posterior with PSIS smoothing enabled. ``deterministic`` selects the deterministic PSIS grid. .. py:method:: delta(*, uh_min_diag: float | None = None, max_ratio: float | None = None) -> Surrogate Enable the alpha-K Hessian Laplace variance correction. ``uh_min_diag`` and ``max_ratio`` set the conditioning gate and per-query magnitude cap on the correction; defaults match the C++ defaults (1e-6, 100.0). Pass <= 0 to disable each guard. The defaults are usually sufficient; tighten them (e.g. uh_min_diag=1e-4) on small-N NEB chains where the Hessian is very poorly conditioned. .. py:method:: psis(*, deterministic: bool = True) -> Surrogate Enable PSIS on the Laplace slice; needs a ``laplace_slice`` base. Raises ``ValueError`` on any other base. .. py:method:: rff(n_features: int | str, force_tol_fraction: float = 0.0) -> Surrogate Fix the feature count, or pass ``"auto"`` to select it. ``"auto"`` (stored as -1) doubles the count until the held-out random-feature posterior matches the exact GP. A positive count still requires a Laplace-slice surrogate. ``force_tol_fraction`` is the share of the 0.0514221 eV/Å force tolerance the automatic rule may spend; 0 derives that share from the gradient noise. Raises ``ValueError`` for a negative count, a string other than ``"auto"``, a positive count on a base other than ``laplace_slice``, or a fraction outside [0, 1). .. py:method:: with_hyperparameter_mode(mode: str) -> Surrogate Select the hyperparameter optimiser, ``"scg"`` or ``"inla"``. Raises ``ValueError`` for any other name. .. py:method:: hssvd(*, no_output_norm: bool = True) -> Surrogate Enable the HS-SVD stable-basis solver path. .. py:property:: label :type: str Short name of the chain, such as ``"lapslice+psis+delta"``.