mixle.inference.reproduce module¶
Reproducibility receipts – record a fit so it can be replayed and checked bit-for-bit (N2).
A fitted model is only trustworthy if someone else can re-derive it. record_fit() captures the
minimal recipe – a fingerprint of the training data, the seed, the estimator, and a fingerprint of the
fitted parameters – into a ReproReceipt. verify_reproducible() refits from that recipe
and confirms the parameters come out identical: replay-based reproducibility, the same discipline the
certificate applies to how a model was estimated, applied to whether the exact fit can be recovered.
Fingerprints are canonical: data and parameters are serialized with floats rounded to a fixed precision
before hashing, so last-bit platform noise doesn’t make an otherwise-identical fit look different, while
any real change to the data or the fitted parameters flips the hash. A model is fingerprinted through its
own to_json (its complete state), so this works for any serializable mixle distribution.
- data_fingerprint(data, *, ndigits=_NDIGITS)[source]
A stable hash of a training dataset (order-sensitive; floats rounded) – identifies the exact input.
- param_fingerprint(model, *, ndigits=_NDIGITS)[source]
A stable hash of a fitted model’s parameters, via its
to_jsonstate (floats rounded).
- class ReproReceipt(data_fingerprint, n, seed, estimator, param_fingerprint)[source]
Bases:
objectThe recipe to re-derive a fit: data + seed + estimator, plus the parameter fingerprint to check.
- data_fingerprint: str
- n: int
- seed: int
- estimator: str
- param_fingerprint: str
- matches_data(data)[source]
Whether
datais the exact dataset this fit was recorded on.
- record_fit(model, data, *, seed, estimator=None)[source]
Record a
ReproReceiptfor a model fitted ondatawithseed(see module docstring).
- verify_reproducible(estimator, data, receipt, *, seed=None, max_its=25)[source]
Refit
estimatorondataand check the fit reproducesreceipt(data + parameters).Returns
{reproducible, data_matches, params_match, refit_fingerprint}.reproducibleis True iff BOTH the data fingerprint and the refit’s parameter fingerprint match the receipt – i.e. the exact fit can be recovered from the recorded recipe.seeddefaults to the receipt’s seed.