mixle.inference.production.monitor module¶
Production model monitoring: watch for drift, retrain, and swap – with provenance and a DOE hook.
A Monitor wraps a fitted model + its estimator + a reference (training) sample. Feed it each
production batch via check() (drift report only) or update() (check, and on drift retrain a
fresh model – recording a new provenance header – and swap it in). Every action is appended to a history
for audit. suggest_samples() ties in mixle.doe so a drift signal (or any model objective) can
drive where to collect new data – space-filling by default, or active-learning against a model objective.
- class Monitor(model, estimator, reference, *, psi_threshold=0.25, ks_threshold=0.2, loglik_shift_threshold=-0.5)[source]
Bases:
objectStateful monitor for one deployed model: drift detection + retrain-and-swap + DOE-driven sampling.
- Parameters:
- check(current)[source]
Drift report of
current(production) data against the reference under the current model.- Parameters:
current (Any)
- Return type:
DriftReport
- update(current, *, retrain=True, combine_reference=True, **fit_kw)[source]
Check drift on
currentand, if drift is flagged andretrain, fit a fresh model (with a new provenance header) and swap it in. Returns{report, action, model, header}and appends tohistory.combine_referenceretrains on reference + current (else current only).
- suggest_samples(bounds, n=10, *, method='lhs', objective=None, seed=None)[source]
Use
mixle.doeto propose where to collect new data (e.g. after drift, or to meet an objective).method='lhs'/'sobol'gives a space-filling batch overbounds(list of(lo, hi)); pass anobjective(x)->floatto switch to active learning (ALC/ALM) that targets where the model is most informative.