compileml.artifact

recalibrate_artifact

def recalibrate_artifact(artifact: dict, latent, y, *, mode: str | None = None, prior_strength: float = 0.0, prior_pi0: float | None = None) -> dict

from compileml.artifact import recalibrate_artifact

Refit calibration on fresh outcomes; model and band edges unchanged.

Args: artifact: An existing decision artifact. latent: Fresh latent scores in [0, 1] (clipped), e.g. the artifact's own latent_micro / micro_scale on the new sample. y: Fresh binary outcomes aligned with latent. mode: Calibration mode for the new table; defaults to the old one. prior_strength: Optional shrinkage weight pulling per-band empirical bad rates toward a prior for the band metadata refresh — small bands get stabilized rates. prior_pi0: The prior rate (defaults to the global bad rate).

Returns: A new artifact dict with updated calibration, refreshed band bad-rate metadata, metadata.recalibration.recalibrated_from set to the old hash, and a new artifact_hash.

Parameters#

NameTypeDefaultKind
artifactdictrequiredpositional
latent—requiredpositional
y—requiredpositional
modestr | NoneNonekeyword-only
prior_strengthfloat0.0keyword-only
prior_pi0float | NoneNonekeyword-only

Returns#

dict

Raises#

  • ValueError

Read from the function body and the private helpers it calls, not inferred. A function that raises nothing has no section here.

Example#

python
from compileml.artifact import recalibrate_artifact
 
fresh = recalibrate_artifact(artifact, latent_new, y_new) # bands and model unchanged

Worked example: recalibrate_artifact →