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: a cheap applicability pre-flight plus a fitted-challenger
propose.- name: str
- cost_hint: float
- applicable(model, data, *, ctx)[source]
Cheap structural gate – can this operator even run on this model/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.
- model: Any
- operator: str
- meta: dict
- 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.
- name: str = 'refit'
- cost_hint: float = 1.0
- max_its: int = 20
- applicable(model, data, *, ctx)[source]
- 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;
applicablehonestly checksConjugateUpdatable).
'forgetting'– power-priorBayesianStreamingEstimator.
- mode: str = 'streaming'
- cost_hint: float = 0.2
- property name: str
- applicable(model, data, *, ctx)[source]
- 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.- name: str = 'auto_select'
- cost_hint: float = 3.0
- max_its: int = 20
- applicable(model, data, *, ctx)[source]
- 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.- name: str = 'recalibrate'
- cost_hint: float = 0.5
- ensemble: int = 256
- seed: int = 0
- applicable(model, data, *, ctx)[source]
- class Recompose(name='recompose', cost_hint=4.0, max_its=30)[source]
Bases:
objectPropose a richer STRUCTURE for the champion: a 2-component mixture of its family, each component warm-fit on a different half of the data so EM starts non-degenerate (avoiding the identical-component collapse). It wins the verify gate only when the data has structure a single component misses — anti-regression keeps it honest. Expensive, so it is registered but kept OUT of the default operator set.
- name: str = 'recompose'
- cost_hint: float = 4.0
- max_its: int = 30
- applicable(model, data, *, ctx)[source]
- class Mutate(name='mutate', cost_hint=4.0, max_its=30)[source]
Bases:
objectGenetic-programming structure search (Koza 1992): apply a random structural mutation to the champion and refit. Moves:
grow(add a bootstrap-fit component),shrink(drop the lowest-weight component), andperturb(bootstrap re-fit). Repeated application inside aPopulation+ the verify gate + a tree-edit genotype distance IS structure induction by selection (cf. Bayesian model merging, Stolcke & Omohundro 1994) — not open research. Registered but OUT of the default set (expensive).- name: str = 'mutate'
- cost_hint: float = 4.0
- max_its: int = 30
- applicable(model, data, *, ctx)[source]
- 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.