Skip to content

thresholds

InsufficientTrialsError

Bases: Exception

Threshold dataclass

relative instance-attribute

absolute instance-attribute

__init__(relative, absolute)

merge(other)

Provide a threshold which is always satisfied if both input thresholds are satisfied.

This is generally a less strict threshold than either input.

SavepointThresholds dataclass

savepoints instance-attribute

__init__(savepoints)

ThresholdCalibrationCheckpointer

Bases: Checkpointer

Calibrates thresholds to be used by a ValidationCheckpointer.

Does this by recording the minimum and maximum values seen across trials, and using them to derive the maximum relative and absolute error one could have across any pair of trials, then multiplying this by a user-provided factor.

thresholds property

__init__(factor=1.0)

Parameters:

Name Type Description Default
factor float

set thresholds equal to this factor of the maximum error seen across trials

1.0

__call__(savepoint_name, **kwargs)

Record values for a savepoint.

Parameters:

Name Type Description Default
savepoint_name SavepointName

name of the savepoint

required
**kwargs ArrayLike

data for the savepoint

{}

trial()

Context manager for a trial.

A new context manager should entered each time the code being calibrated is called, and exited at the end of code execution. If each of these calls is done with slightly perturbed inputs, this calibrator will be able to estimate an error tolerance for each savepoint call.

cast_to_ndarray(array)