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-score Objective – 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 typed Space for the config that builds the best model under a held-out Objective, with three interchangeable backends:

    • method='bo' – encode the space as a numeric box and drive mixle.doe.minimize().

    • method='evolutionary'– a (mu + lambda) loop over Space.sample() / Space.neighbors().

    • method='bandit' – delegate the which-operator decision to the OperatorBandit via a Population.

    build_fn(config) -> fitted model is caller-supplied, so search is 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:
  • data (Sequence[Any]) – the raw dataset.

  • space (Any | None) – reserved for the Phase-2 typed search space; must be None in Phase 1.

  • criterion (str | Objective) – 'bic' (delegate to the automatic in-sample pick) or a proper-score Objective (add the held-out verify gate on top of BIC).

  • verify (bool) – when criterion is an Objective, 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. For criterion='bic' it carries the fitted automatic model with verified=False (no out-of-sample test was requested). For an Objective criterion with verify=True it carries the gate verdict and verified reflects 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 space for the config whose build_fn model scores best on a held-out split.

Parameters:
  • space (Space) – the typed Space to 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 over sample / neighbors), or 'bandit' (delegate the operator policy to an OperatorBandit).

  • 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 / lam for the evolutionary loop, operators / size for the bandit population).

Returns:

A SearchResult with best_config / best_model / best_score (native orientation) / history.

Return type:

SearchResult

class SearchResult(best_config, best_model, best_score, history=<factory>)[source]

Bases: object

The outcome of a search() (or Population.run()) run.

Parameters:
best_config: dict[str, Any]
best_model: Any
best_score: float
history: list[dict[str, Any]]