cleverly.validation.RefutationCheckpoint#
- class cleverly.validation.RefutationCheckpoint(directory: str | PathLike[str])[source]#
Keep each finished draw of the long refutation tests as a file in a directory.
Pass it as
refute(..., checkpoint=RefutationCheckpoint(directory)). Each finished draw ofdummy_outcome,simulated_outcome,plasmode,bootstrap_stabilityandbootstrap_measurement_erroris written as one JSON file, under a temporary name and then renamed, so a call stopped mid-write never reads a partial file. Run the same call again with the same directory and it loads the stored draws, refits only the missing ones, and returns the report an uninterrupted call returns. The placebo, noise and subset tests are not stored.The directory records the request on first use: the estimator’s class and settings, the data’s fingerprint, the resolved seed and repeat seeds, every estimate and standard error of the fit, the estimand, each stored test’s draw count, process or declaration, bands, rule and resampling, and the versions of
cleverly, NumPy, SciPy and scikit-learn. A call whose request differs in any part refuses, naming the part. Two development commits can share onecleverlyversion, so give each commit its own directory. An unseeded fit draws its seed at the first call; the directory records it, and a resume passes it back asrandom_state=. A directory that holds no draw yet takes a new request. A facade call whose answer is already cached returns it without reading the draws. Run one call per directory at a time: the request file is not locked.- Parameters:
- directory
stroros.PathLike Where the files go. It is created when missing.
- directory
Methods#
- RefutationCheckpoint.child(name: str, *, record: bool = True) RefutationCheckpoint[source]#
The checkpoint of one candidate of a variable-importance run.
- Parameters:
- Returns:
RefutationCheckpointA checkpoint in a subdirectory of this one.
- Raises:
CapabilityErrorIf two names map to one subdirectory.
- RefutationCheckpoint.load(test: str, replicate: int) EmpiricalRefitRecord | ReplicationFailure | None[source]#
Return the stored draw
replicateoftest, orNonewhen there is none.- Parameters:
- Returns:
EmpiricalRefitRecord,ReplicationFailureorNoneThe stored draw, or
None.
- RefutationCheckpoint.save(test: str, replicate: int, outcome: Any) None[source]#
Store draw
replicateoftest.- Parameters:
- test
str The test.
- replicate
int The draw’s index.
- outcome
EmpiricalRefitRecordorReplicationFailure What the draw returned.
- test