Add FullyBayesianGP: HMC-marginalized hyperparameters + Bayesian model averaging#10
Open
blankjul wants to merge 1 commit into
Open
Add FullyBayesianGP: HMC-marginalized hyperparameters + Bayesian model averaging#10blankjul wants to merge 1 commit into
blankjul wants to merge 1 commit into
Conversation
…odel averaging
Point-estimating the GP hyperparameters by maximum likelihood gives a variance
conditional on one length-scale/nugget guess -- overconfident when the data is
scarce or noisy and the likelihood is flat or multi-modal. FullyBayesianGP instead
draws posterior samples of (theta, noise) by Hamiltonian Monte Carlo and predicts
by Bayesian model averaging:
mean = <mu_s>, var = <sigma2_s> + Var_s(mu_s)
-- the extra between-sample term is the hyperparameter uncertainty MLE drops.
The machinery is reused, not reinvented: the HMC potential is the same DACE profile
likelihood the Kriging search already descends (via DaceProblem), so no new gradient
code -- log-likelihood = -(n/2) log(obj) and its gradient follow by the chain rule
through the log. Each posterior sample becomes a frozen Dace fit; prediction averages
their Predictions.
New:
- dace/hmc.py: generic HMC with dual-averaging step-size adaptation and trajectory-
length jitter (breaks fixed-L resonance). Recovers a known Gaussian posterior.
- models/bayesian.py: FullyBayesianGP backend + the _GPPosterior wrapper.
Verified: HMC recovers a 3D Gaussian (mean/cov); the log-posterior gradient matches
finite differences to ~1e-9; the fit is deterministic given the seed; DACE golden
stays 19/19 byte-identical (additive change). On noisy d=4/n=40 data the model-average
reports honest uncertainty where MLE-Kriging is overconfident: mean NLPD ~0.2 vs ~0.9
(4x better calibrated) at comparable RMSE, and never catastrophically overconfident
(MLE is on ~half the seeds). Not a free lunch on clean, data-rich problems -- there
MLE-ARD already nails the fit -- so it is scoped to the scarce/noisy regime where
calibration matters (Bayesian optimization).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new surrogate backend,
FullyBayesianGP(inpysurrogate.models), that marginalizes the GP length-scales and nugget by Hamiltonian Monte Carlo instead of point-estimating them by maximum likelihood, then predicts by Bayesian model averaging:The extra between-sample term is the hyperparameter uncertainty an MLE fit drops — which is why an MLE variance is overconfident on scarce/noisy data (one length-scale guess, no acknowledgement it was a guess).
Why it's cheap to add
No new gradient code. The HMC potential is the DACE profile likelihood the Kriging search already descends (
log-lik = -(n/2)·log(obj)), so_GPPosteriorjust wrapsDaceProblemthrough alogtransform plus a log-space prior. Each posterior sample becomes a frozenDacefit (optimizer=None); prediction averages theirPredictions. Builds directly on thePriorfoundation from #9.New files
dace/hmc.py— generic HMC with dual-averaging step-size adaptation and trajectory-length jitter (breaks the fixed-leapfrog resonance that was under-sampling the widest posterior direction).models/bayesian.py—FullyBayesianGP+ the_GPPosteriorwrapper.tests/models/test_bayesian.py— 10 tests.Verification
pyclawd checkgreen; fast tier 531 passed.Honest scope
The calibration test asserts the aggregate NLPD win (robust) rather than per-seed (which MLE occasionally wins when it happens to be calibrated) — marked
@slow.🤖 Generated with Claude Code