mixle.inference.reproduce module¶
Reproducibility receipts – record a fit so it can be replayed and its content re-checked (N2).
A fitted model is only reproducible if someone else can re-derive it from the same complete request.
fit_and_record() executes one materialized request; record_fit() binds an existing result to
the exact ordered data, estimator code and state, optimizer code, seed and fit policy, dependency/source
environment, and returned model. verify_reproducible() re-executes that request and requires every
declared identity and observed result to match.
The legacy data_fingerprint and param_fingerprint remain tolerance-equivalent diagnostics:
floats are rounded to _NDIGITS (10) decimal places. The v2 receipt additionally carries full exact
SHA-256 data and model digests. Therefore:
last-bit drift may retain the diagnostic fingerprint but fails exact data/model or environment checks;
a real content, executable, policy, dependency, or source-tree change fails its named check;
a verdict cannot pass merely because an expected check was omitted.
A matching replay certifies identity and execution under the recorded contract, not statistical correctness; calibration and model-quality claims require their own evidence.
- 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, max_its=10, delta=1e-09, schema_version='mixle-repro-v2', data_digest='', model_digest='', estimator_implementation_digest='', estimator_state_digest='', optimizer_implementation_digest='', dependency_digest='', environment=<factory>, fit_policy=<factory>, fit_policy_digest='', execution_digest='', receipt_digest='')[source]
Bases:
objectThe complete executable recipe and observed result needed to re-derive a fit.
max_its/deltamust match whatever was actually passed to the originaloptimize()call that produced the fingerprinted model (they default tooptimize()’s own defaults). Without these,verify_reproducible()cannot replay the same fit – an iterative estimator refit with a different iteration budget or convergence tolerance can land at a different (if nearby) optimum and spuriously reportreproducible: Falsefor a fit that would have reproduced exactly under its own original settings.- Parameters:
data_fingerprint (str)
n (int)
seed (int)
estimator (str)
param_fingerprint (str)
max_its (int)
delta (float | None)
schema_version (str)
data_digest (str)
model_digest (str)
estimator_implementation_digest (str)
estimator_state_digest (str)
optimizer_implementation_digest (str)
dependency_digest (str)
fit_policy_digest (str)
execution_digest (str)
receipt_digest (str)
- matches_data(data)[source]
Whether
datais the exact dataset this fit was recorded on.
- record_fit(model, data, *, seed, estimator=None, max_its=10, delta=1.0e-9, fit_options=None)[source]
Record a
ReproReceiptfor a model fitted ondatawithseed(see module docstring).Pass the same
max_its/deltaactually used for the fit being recorded (they default tooptimize()’s own defaults);verify_reproducible()replays the fit with these exact values.
- fit_and_record(data, estimator, *, seed, max_its=10, delta=1.0e-9, fit_options=None)[source]
Execute one materialized fit and return the model with its complete replay receipt.
- verify_reproducible(estimator, data, receipt, *, seed=None, max_its=None)[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.max_itsdefaults to the receipt’s own recorded value (the iteration budget the original fit actually used);deltaalways replays the receipt’s recorded value – a refit run with a different iteration budget or convergence tolerance than the original fit can land at a different (if nearby) optimum and spuriously reportreproducible: Falsefor a fit that would have reproduced exactly under its own original settings.