feat(regime): regime-conditional surrogate (#105)#109
Merged
Conversation
Add `trade_study.regime` on top of #82's surrogate so studies that gate on a regime feature (e.g. n_samples, noise level) can borrow strength across regimes and interpolate factor recommendations across continuous regime axes instead of relying on hard buckets. API: - `fit_regime_surrogate(results, regime_factors, factors, *, method, seed, n_estimators) -> RegimeSurrogate`. Validates non-empty regime factors and disjoint name sets, then fits a single per-observable surrogate over the joint `regime_factors + factors` input space. - `RegimeSurrogate.predict(regime, config)` / `predict_batch(regime, configs)` for inspection / plotting. - `RegimeSurrogate.uncertainty(regime, config)` propagates the GP-only uncertainty contract from `SurrogateModel`. - `RegimeSurrogate.recommend(regime, *, objective, mode, n_candidates, seed, candidates)` samples design-factor candidates via Sobol' (or uses an explicit pool) and returns the surrogate-best config. Docs: new `docs/api/regime.md` page wired into the mkdocs nav. Tests: 13 new tests covering validation, predict / predict_batch shape, GP uncertainty, RF uncertainty raising, recommend tracking the regime optimum, mode='max' inversion, and recommend's input validation. `regime.py` coverage: 100%. Suite: 307 passing, 99.5% project coverage. Closes #105.
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 #105. Builds on #82.
Summary
Adds
trade_study.regimeso studies that currently gate on a regime feature (e.g.n_samples,noise_level) can:n=1kinform predictions atn=3kinstead of being thrown away.API
SurrogateModelover the jointregime_factors + factorsinput space, so the regime descriptors are additional input dimensions rather than separate models per bucket.recommend()samplesn_candidatesdesign configs via scrambled Sobol' (or accepts an explicitcandidates=pool) and returns the best surrogate prediction undermode in {"min", "max"}.SurrogateModel.Validation
regime_factorsmust be non-empty and disjoint fromfactors.recommend()validatesmode,objective, and non-empty candidate pools.Docs
New
docs/api/regime.mdpage in the mkdocs nav, right after Surrogate.Tests
13 new tests covering validation, predict/predict_batch, GP uncertainty, RF uncertainty raising,
recommend()tracking the optimum across regime values, mode inversion, and input validation.regime.pycoverage: 100%. Suite: 307 passing, 99.5% project coverage.Composes with
RegimeSurrogatewraps aSurrogateModel.