Give each per-variable QRF model its own seed - #214
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Reviewed with a fresh pass against the base commit. The bug and the fix both reproduce, and the tests genuinely fail without the change — copying the new test file onto The most important finding is about merge order: #219 regresses this fix rather than superseding it. Verified in its diff — its sequential branch ends To doBefore merging
Worth doing
Optional
The uint32 bound is genuinely required, not defensive: Note the 8 |
|
Review of 24b8766: No implementation defect found in this PR. The remaining merge blocker is the inherited Lint failure. Merge blocker — incorporate #218 and rerun CI. The Lint job fails because Ruff would reformat five unchanged Markdown files: Validation at the reviewed head: 114 affected tests passed. Focused seed checks rejected nine invalid inputs, verified four valid derivations, and completed two real Optuna tuning runs at the NumPy uint64 maximum seed. Unit/smoke and changelog CI passed; Lint failed. The current constructor validation, unknown-variable error, bounded child seeds, and per-target tuning streams should all survive the #219 integration. Integration: read-only merge checks found no textual conflicts in the cumulative #218 + #214 + #215 + #216 + #217 tree. This is not a combined-suite result. #219 conflicts with #214, #215, #217, and #218, so its later rebase must retain the seed, Matching, API, and formatter fixes. The PR description cites an older final commit and historical green checks; update it to the resulting implementation and current validation. |
Every per-variable model builds its own generator from the seed it is given, and all of them were handed self.seed. They therefore drew the same random quantiles in the same row order, so variables imputed together came out rank-comonotonic whatever their dependence in the donor: three targets with nil conditional dependence reproduced at 0.71 Spearman, 0.11 after this change. The offset follows the convention already used for the subsampling seed in _apply_max_train_samples. QRF also now accepts a seed argument; there was previously no way for a caller to vary the draws. Fixes #207
Per review, two ways the fix could be undone silently. _seed_for_variable fell back to offset 0 when a variable was not in imputed_variables, which hands it the same draws as the first target - the comonotonicity this method exists to prevent, reintroduced with no symptom. It now raises. Today's call sites all pass post-preprocessing names, so this is about the next refactor, not current behaviour. Seeds were validated lazily inside _seed_for_variable, so QRF(seed=-5) constructed fine and only failed part-way through fit, where the blanket handler rewrapped the ValueError as RuntimeError. Validation now happens in __init__, bools included, and the test asserts ValueError at construction rather than RuntimeError at fit. Also drops the docs reformatting, which belongs to #218 alone.
24b8766 to
a8c94bd
Compare
Critical fixedUpdated the branch onto current Should-address fixedRefreshed the description to match the constructor validation, bounded per-target seeds, unknown-target error, and current validation evidence. Retained the warning that joint stochastic draws change. Verification
Pushed head: GitHub CI: All seven current-head checks passed, including lint, changelog, Python 3.12 smoke tests, Python 3.14 tests with R, and Vercel preview. GitHub reports this pull request as mergeable. (run). |
Fixes #207.
Quantile regression forests (QRF) now use a distinct seed for each target during fitting, target-specific subsampling, and numeric and categorical hyperparameter tuning. This removes the shared random quantile stream that coupled stochastic predictions across targets.
QRF(seed=...)controls reproducibility.Child seeds wrap within scikit-learn's supported range, including when the base seed is
4294967295. The constructor accepts integer seeds from zero through that limit orNone, and rejects invalid values, including booleans. An unknown target raises an error when deriving a seeded stream.Stochastic output changes, so downstream datasets using joint draws need regeneration and checks of joint-tail statistics.
Validation: 114 affected tests passed before the base rebase; verification confirmed that program and test contents remain unchanged. Focused checks covered invalid seeds, boundary derivations, and numeric and categorical tuning. The branch includes the shared lint repair from #218; Ruff 0.16.7 formatting and
git diff --checkpass.Checks for current head
a8c94bd.