feat: expose convergence diagnostics from VBPCA.fit() and select_n_components()#100
Merged
Conversation
…mponents() Closes #99 - _converge.py: convergence_check() now stores a structured reason tag (_convergence_reason) in the learning curve dict via _cost_criteria_tagged() - _pca_full.py: promotes _convergence_reason to convergence_reason in lc after the training loop, defaulting to 'maxiters' - estimators.py: VBPCA gains n_iter_, convergence_reason_, learning_curve_ fitted attributes populated after fit() - model_selection.py: trace entries include n_iter and convergence_reason - Tests: 5 new tests covering all three layers
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.
Closes #99
Summary
Expose convergence diagnostics that
pca_full()already computes butVBPCA.fit()previously discarded. This enables downstream analysis of convergence behavior — particularly important for optimizing convergence parameters wherewall_secondsis an unreliable proxy.Changes
_converge.py_cost_criteria_tagged()returns(reason_tag, message)tuples instead of bare stringsconvergence_check()stores a structured_convergence_reasontag in the learning curve dict when a criterion firesangle,earlystop,rms_plateau,cost_plateau,cfstop_rel,cfstop_curv,composite,slowing_down_pca_full.py_convergence_reason→convergence_reasonin lc, defaulting to"maxiters"estimators.pyThree new fitted attributes on
VBPCA:n_iter_: int | None— iterations completedconvergence_reason_: str | None— structured reason tag or"maxiters"learning_curve_: dict | None— full per-iteration history (rms, prms, cost, angle, phase timings)model_selection.py_fit_candidate()trace entries now includen_iterandconvergence_reasonTests
test_estimators.py: diagnostics exposed after fit, maxiters reason, angle reason, None before fittest_model_selection.py: trace entries contain convergence diagnosticsMotivation
Investigation revealed that
niter_broadprior=100(the default) suppresses convergence checks, causing 30–93% iteration waste with negligible quality improvement:These diagnostics enable data-driven optimization of
niter_broadpriorand convergence thresholds.