mixle.evolve.search module¶
auto_select + search: the “propose a better mixle model from data” / config-search front door.
auto_select()(Phase 1) elevates the existing automatic engine (mixle.utils.automatic.get_estimator()) into the evolve contract and – when the criterion is a proper-scoreObjective– adds the held-out champion/challenger gate on top of the in-sample BIC pick, so the returned model wins out of sample, not merely on BIC.search()(Phase 2-3) searches a typedSpacefor the config that builds the best model under a held-outObjective, with three interchangeable backends:method='bo'– encode the space as a numeric box and drivemixle.doe.minimize().method='evolutionary'– a (mu + lambda) loop overSpace.sample()/Space.neighbors().method='bandit'– delegate the which-operator decision to theOperatorBanditvia aPopulation.
build_fn(config) -> fitted modelis caller-supplied, sosearchis family-agnostic.
- auto_select(data, *, space=None, criterion='bic', verify=True, holdout=0.25, seed=0, max_its=20)[source]
Infer and fit a model from raw
data, optionally gated by a held-out proper score.- Parameters:
space (Any | None) – reserved for the Phase-2 typed search space; must be
Nonein Phase 1.criterion (str | Objective) –
'bic'(delegate to the automatic in-sample pick) or a proper-scoreObjective(add the held-out verify gate on top of BIC).verify (bool) – when
criterionis anObjective, whether to run the held-out gate (the BIC pick fitted on the train split is the champion; the BIC pick refitted on all data is the challenger, promoted only if it wins out of sample).holdout (float) – held-out fraction for the proper-score gate.
seed (int) – RNG seed for the split and sampled objectives.
max_its (int) – EM iterations for the fits.
- Returns:
An
ImprovementResult. Forcriterion='bic'it carries the fitted automatic model withverified=False(no out-of-sample test was requested). For anObjectivecriterion withverify=Trueit carries the gate verdict andverifiedreflects whether the full-data model beats the train-only model out of sample.- Return type:
ImprovementResult
- search(space, data, *, objective, build_fn, method='bo', n_iter=25, holdout=0.25, seed=0, **method_kwargs)[source]
Search
spacefor the config whosebuild_fnmodel scores best on a held-out split.- Parameters:
space (Space) – the typed
Spaceto search.data (Sequence[Any]) – the raw dataset (split once into train/val here for the inner objective).
objective (Objective) – the held-out
Objective(lower-is-better aware).build_fn (Callable[[dict[str, Any]], Any]) – caller-supplied
config -> fitted model(the search is family-agnostic).method (str) –
'bo'(Bayesian optimization over the numeric box),'evolutionary'(a (mu + lambda) loop oversample/neighbors), or'bandit'(delegate the operator policy to anOperatorBandit).n_iter (int) – search budget (BO acquisition steps / evolutionary generations / bandit generations).
holdout (float) – held-out fraction for the inner objective.
seed (int) – RNG seed.
method_kwargs (Any) – backend-specific knobs (e.g.
mu/lamfor the evolutionary loop,operators/sizefor the bandit population).
- Returns:
A
SearchResultwithbest_config/best_model/best_score(native orientation) /history.- Return type:
SearchResult