mixle.data.hashing module

Stable content hashing of training datasets, for reproducible model provenance.

dataset_hash(data) returns a hex SHA-256 over a canonical byte encoding of the records, so the exact dataset that trained a model can be fingerprinted and recorded in its header (see mixle.inference.production.provenance). The hash is order-sensitive (the same records in a different order hash differently) – it identifies an exact training sequence; pass sort=True for an order-insensitive fingerprint (records are hashed independently and combined commutatively).

model_hash(model)[source]

Hex SHA-256 fingerprint of a fitted model’s parameters (its serialized state).

Stable across processes: hashes the canonical form of to_serializable(model), so the same model always yields the same hash and two models hash equal iff their serialized parameters match. Used to fingerprint a checkpoint and chain EM iteration lineage (see mixle.inference.production.provenance).

Parameters:

model (Any)

Return type:

str

dataset_hash(data, *, sort=False, max_records=None)[source]

Hex SHA-256 fingerprint of data (a sequence of records or a DataSource).

sort=False (default) is order-sensitive (exact training sequence). sort=True combines per-record hashes commutatively for an order-insensitive fingerprint. max_records truncates (the count is mixed in, so a truncated hash never collides with a full one).

Parameters:
Return type:

str