mixle.evolve.operators module¶
The propose contract: a uniform ImprovementOperator over existing fit mechanisms.
Every “improve” move – a warm-start refit, an online update, an auto-select, a recalibration – is one operator with the same shape, so they become interchangeable proposal moves the driver can schedule and the gate can compare. Each operator body is a thin shell over a verified-present API:
Refit->mixle.inference.estimation.optimize()warm-started from the champion.OnlineUpdate-> the streaming estimators (StreamingEstimator/IncrementalEstimator/
BayesianStreamingEstimator).update.
AutoSelect->mixle.utils.automatic.get_estimator()->optimize.Recalibrate-> a post-hoc affine spread-temperature wrap that recalibrates the predictivewithout refitting the base parameters.
Operators are registrable through a scoped registry (register_operator / unregister_operator)
that mirrors the “register, don’t branch” pattern without polluting the global Detector registry.
- class ImprovementOperator(*args, **kwargs)[source]
Bases:
ProtocolA uniform proposal move: an applicability pre-flight plus a fitted-challenger
propose.- applicable(model, data, *, ctx)[source]
Structural gate: whether this operator can run on the model and data.
- class Candidate(model, operator, parent_hash=None, meta=<factory>)[source]
Bases:
objectA proposed, already-fitted challenger plus the provenance of how it was made.
- class Refit(name='refit', cost_hint=1.0, max_its=20)[source]
Bases:
objectRe-fit the champion’s family on fresh data, warm-started from the champion’s parameters.
- applicable(model, data, *, ctx)[source]
Return whether
modelcan be re-fit on a non-empty batch.
- class OnlineUpdate(mode='streaming', cost_hint=0.2)[source]
Bases:
objectFold a fresh batch into the champion via a streaming estimator.
mode:'streaming'– decay-modeStreamingEstimator(running-accumulator forgetting).'incremental'– Neal-HintonIncrementalEstimator(replace one chunk).'posterior_carry'– exact recursive-BayesBayesianStreamingEstimator(needs aconjugate family;
applicablechecksConjugateUpdatable).
'forgetting'– power-priorBayesianStreamingEstimator.
- property name: str
Registry name including the selected online-update mode.
- applicable(model, data, *, ctx)[source]
Return whether the selected update mode is legal for
modelanddata.
- class AutoSelect(name='auto_select', cost_hint=3.0, max_its=20)[source]
Bases:
objectInfer an estimator from the raw data (
get_estimator) and fit it – a possible family swap.- applicable(model, data, *, ctx)[source]
Return whether there is data available for automatic family selection.
- class Recalibrate(name='recalibrate', cost_hint=0.5, ensemble=256, seed=0, grid=(0.6, 0.75, 0.9, 1.0, 1.1, 1.25, 1.5, 2.0))[source]
Bases:
objectLearn a predictive spread temperature
Tthat flattens the PIT, no parameter refit.applicablerequires a sampler (used both to estimate the predictive center and to evaluate PIT calibration). The temperature is chosen on the train split by minimising the PIT calibration error over a small grid;T == 1(the identity) is always in the grid, so the recalibrated model can never be worse-calibrated than the base on the fitting data.- applicable(model, data, *, ctx)[source]
Return whether
modelcan be sampled and the batch is non-empty.
- class Recompose(name='recompose', cost_hint=4.0, max_its=30)[source]
Bases:
objectPropose a richer two-component mixture structure for the champion family.
Each component is warm-fit on a different half of the data so EM starts away from the identical-component solution. The normal verification gate decides whether the additional structure improves held-out evidence enough to promote. The operator is registered but omitted from the default set because it is intentionally more expensive than the conservative updates.
- applicable(model, data, *, ctx)[source]
Return whether the model can be re-estimated on enough rows for a split.
- class Mutate(name='mutate', cost_hint=4.0, max_its=30)[source]
Bases:
objectApply a random structural mutation to the champion and refit.
Available moves are
growfor adding a bootstrap-fit component,shrinkfor dropping the lowest-weight component from an existing mixture, andperturbfor a bootstrap re-fit. Repeated use inside aPopulationgives the search driver a structure-induction move, while the verification gate remains responsible for promotion. The operator is registered but omitted from the default set because it is comparatively expensive.- applicable(model, data, *, ctx)[source]
Return whether the model can be structurally mutated and re-fit.
- register_operator(operator)[source]
Register
operatorin the scoped evolve operator registry (returns it for decorator use).- Parameters:
operator (ImprovementOperator)
- Return type:
ImprovementOperator
- unregister_operator(name)[source]
Remove a previously-registered operator by name (no-op if absent).
- Parameters:
name (str)
- Return type:
None
- registered_operators()[source]
A copy of the current scoped operator registry.