mixle.inference.production.provenance module¶
Reproducible model artifacts: a descriptive header logging what trained a model and how.
A Header records the estimator/model configuration, a summary + content hash of the training
data, the data schema, the training settings and final objective, timing, and the software environment
(versions + git commit). Attach one at fit time with fit_with_provenance() (or build one for any
model + data with build_header()) so a fitted model is self-describing and a run can be reproduced
and audited. Headers are plain dicts under the hood (Header.to_dict()), so they serialize to
JSON alongside the model.
- environment_info()[source]
Snapshot of the software/hardware environment for reproducibility.
- Return type:
- class Header(model_type, model_summary, schema, n_records, dataset_hash, final_loglik, model_hash=None, training=<factory>, timing=<factory>, resources=<factory>, environment=<factory>, created_at='')[source]
Bases:
objectA descriptive, serializable provenance record for a fitted model.
- Parameters:
- model_type: str
- model_summary: str
- dataset_hash: str
- training: dict
- timing: dict
- resources: dict
- environment: dict
- created_at: str = ''
- build_header(model, data, *, training=None, started=None, finished=None, final_loglik='auto', resources=None, hash_sort=False, hash_max_records=None)[source]
Build a
Headerformodeltrained ondata(does not run any fitting).
- fit_with_provenance(data, estimator, *, seed=None, lineage=True, **optimize_kw)[source]
Fit
estimatorondatavia EM (mixle.inference.optimize()) and return(model, header), the model carrying a.headerHeaderwith the data hash, the final model hash, schema, training settings + per-iteration convergence trace, timing, final log-likelihood, and environment. Pass your ownout=to print iterations (then the trace is not captured).With
lineage=True(default) each iteration in the convergence trace also records the accepted model’smodel_hashand the previous iteration’sparent_hash, forming a verifiable hash chain (check it withverify_lineage()). This fingerprints the model every iteration; passlineage=Falseto skip it for very large models. Any useron_step=is still called.
- verify_lineage(header)[source]
Check that a header’s per-iteration convergence trace is an intact model-hash chain.
Returns True when every iteration that recorded a
model_hashnames the previous such iteration’s hash as itsparent_hash(so iteration i+1 provably descends from i), and True vacuously when the trace carries no lineage (fit_with_provenance(lineage=False)or a customout). Returns False on the first broken link. Accepts aHeaderor itsto_dict.