Add variance-budget and scale-invariant fit training diagnostics#40
Open
bwengals wants to merge 4 commits into
Open
Add variance-budget and scale-invariant fit training diagnostics#40bwengals wants to merge 4 commits into
bwengals wants to merge 4 commits into
Conversation
jessegrabowski
approved these changes
Jun 23, 2026
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.
Adds training diagnostics that describe how a GP splits the response variance across the mean function, the GP signal, and the observation noise, plus a scale-invariant likelihood-based "excess fit" metric for both VFE and the exact GP.
Motivation
excess_fit_per_nwas sensitive to the mean and scale ofy: the GP defaults to a zero mean function andyenters the fit uncentered, and the metric referencedsigma**2, so the log-determinant's scale dependence was not cancelled. Its documented "goes to 0 at the noise floor" was also wrong (it sat at -0.5).What's added
variance_budget(gp, X, y)(model-agnostic): decomposes the response variance into mean / GP-signal / noise via the law of total variance,Var(y) = Var(m(X)) + mean(diag(K)) + mean(sigma(X)**2). Returns the three contributions, their fractions (sum to 1), andvar_ratio = total / Var(y)for calibration. Invariant to the mean and scale ofy; works for any mean function, composed (sum) kernels, and scalar or heteroskedasticsigma.vfe_diagnostics: gains the four budget fields, andexcess_fit_per_nis redefined tofit_per_n + 0.5*log(2*pi*Var(y - m(X))) + 0.5. Referencing the residual variance instead ofsigma**2cancels the log-determinant's scale term, so the metric is scale-invariant and reads 0 against a constant-mean Gaussian.unapproximated_diagnostics(gp, X, y)(new): the exact-GP analogue, built onmarginal_log_likelihood. Reportsmll/fit/logdet, per-point fit and complexity, the same scale-invariantexcess_fit_per_n, and the variance budget.All new fields flow through
compile_scipy_diagnostics,tracked_minimize, andto_idataautomatically via the namedtuple plumbing.Heteroskedastic sigma
Every metric handles
sigmaas a scalar or anX-dependent length-N vector (sigma * ones(N)thenmean(sigma**2)).Related
Relates to #7 (live training monitor dashboard): each new namedtuple field is a ready-to-plot series. Does not close any open issue.
Test plan
pytest tests/275 passedpre-commit run --all-filesclean (runs on every commit)scripts/run_mypy.py37/37 pass📚 Documentation preview 📚: https://ptgp--40.org.readthedocs.build/en/40/