fix(bench): respect alpha kwarg + leaderboard row (UNI2-h α-CV → 0.4338)#140
Open
sajadghawami wants to merge 2 commits into
Open
fix(bench): respect alpha kwarg + leaderboard row (UNI2-h α-CV → 0.4338)#140sajadghawami wants to merge 2 commits into
sajadghawami wants to merge 2 commits into
Conversation
The --alpha CLI flag and the train_test_reg alpha kwarg were declared but ignored — trainer.py unconditionally overwrote alpha with 100/(d*g) before constructing the Ridge model, and benchmark.py never forwarded args.alpha into the call. Two minimal changes: - trainer.py: only apply the 100/(d*g) heuristic when alpha is None - benchmark.py: forward args.alpha to train_test_reg No behavior change for existing users (default alpha is unchanged when the flag is omitted). Enables the existing CLI flag to actually work, which is needed for ridge-alpha hyperparameter tuning on top of frozen-encoder features.
Same UNI2-h backbone, same PCA-256+Ridge protocol — only ridge alpha is chosen per outer fold via inner 5-fold CV on training spots (no test leakage). Modal selected α ≈ 5000. Empirical impact: 0.4141 → 0.4338 (+0.0197). All 9 tasks improve over the default-α baseline. Made possible by the alpha-kwarg bug fix in the preceding commit. Per-task numbers reproduced via the changes in this PR with --alpha selected per outer fold by inner 5-fold CV on the train split.
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.
Summary
The
--alphaCLI flag and thetrain_test_reg(alpha=...)kwarg are currently declared but ignored:src/hest/bench/trainer.pyoverwritesalphawith100 / (d * n_genes)at line 12 (CPUridge) and line 26 (ridge-gpu) before constructing the Ridge model.src/hest/bench/benchmark.pyline 309 callstrain_test_reg(...)without passingalphaat all.So passing
--alpha Xon the CLI has no effect.This PR is a pure bug fix:
trainer.py: apply the100/(d·n_genes)heuristic only whenalpha is Nonebenchmark.py: forwardargs.alphaintotrain_test_regNo behavior change for existing users: when
--alphais omitted, the default formula is still used.Why this matters
The default α =
100 / (d · n_genes)≈0.0078(for PCA-256, 50 genes) is several orders of magnitude smaller than the cross-validated optimum (~5000) we found across nine HEST-Bench tasks. With the flag plumbed through, ridge-alpha hyperparameter tuning becomes possible, and on UNI2-h with the existing benchmark protocol (PCA-256, leave-one-patient-out folds) we observed:All 9 tasks improved. α was selected using inner folds on training spots only — no test leakage.
Test plan
--alphareproduces the default (100/(d·n_genes)) — verified via theprint(f"Using alpha: {alpha}")line.--alpha 5000now propagates to the Ridge model (was previously silently ignored).Notes
A follow-up could add a
--method ridge-cvmode usingsklearn.linear_model.RidgeCV(closed-form GCV) for automatic α selection. I kept this PR strictly to the bug fix to keep the footprint minimal.