pbm_calibrator
PBMCalibrator
¶
Bases: Trace
A trace to generate a PlattBinnerMarginalCalibrator given a set of predictions.
Unlike many common calibration error correction algorithms, this one has actual theoretical bounds on the quality
of its output: https://arxiv.org/pdf/1909.10155v1.pdf. This trace is commonly used together with the Calibrate
NumpyOp for postprocessing. This trace will collect data from whichever mode
it is set to run on in order to
perform empirical probability calibration. The calibrated predictions will be output on epoch end. The trained
calibration function will also be saved if save_path
is provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_key |
str
|
Name of the key that corresponds to ground truth in the batch dictionary. |
required |
pred_key |
str
|
Name of the key that corresponds to predicted score in the batch dictionary. |
required |
mode |
Union[str, Set[str]]
|
What mode(s) to execute this Trace in. For example, "train", "eval", "test", or "infer". To execute regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument like "!infer" or "!train". |
'eval'
|
ds_id |
Union[None, str, Iterable[str]]
|
What dataset id(s) to execute this Trace in. To execute regardless of ds_id, pass None. To execute in all ds_ids except for a particular one, you can pass an argument like "!ds1". |
None
|
output_name |
Optional[str]
|
What to call the output from this trace. If None, the default will be ' |
None
|
save_path |
Optional[str]
|
Where to save the calibrator generated by this Trace. If None, then no saving will be performed. |
None
|
save_if_key |
Optional[str]
|
Name of a key to control whether to save the calibrator. For example "since_best_acc". If provided, then the calibrator will only be saved when the save_if_key value is zero. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If 'save_if_key' is provided but no 'save_path' is given. |