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.
Source identity is taken from the ambient repository when there is one, and otherwise from the installed artifact’s embedded build provenance.
provenance_sourcenames which, because “no repository here” and “a clean repository” are different facts and were previously reported the same way.- 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:
- 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 records a digest-chained transition from the previous accepted model, and a terminal record binds the model actually returned by the optimizer (check it withverify_lineage(); the digests bind the iteration sequence and the model, not the header’s dataset hash, record count, or log-likelihood values, which stay recorded claims). This fingerprints the model every iteration; passlineage=Falseto skip it for very large models. Any useron_step=is still called.
- verify_lineage(header)[source]
Verify a complete execution-recorded EM transition chain.
Missing lineage is an unverified result, never a vacuous success. Each iteration must bind its actual model hash to the previous model and transition digests, all records must share one run id, and the final executed model hash must equal the header’s fitted-model hash.