incerto.calibration.BetaCalibrator#

class incerto.calibration.BetaCalibrator(method='mle')[source]#

Bases: BaseCalibrator

Beta Calibration for binary classification (Kull et al., 2017).

Fits a Beta distribution to map uncalibrated probabilities to calibrated probabilities. More flexible than Platt scaling.

Reference:

Kull et al., “Beta calibration: a well-founded and easily implemented improvement on logistic calibration” (AISTATS 2017)

Parameters:

method (str) – Fitting method (‘mle’ or ‘map’)

__init__(method='mle')[source]#
Parameters:

method (str)

Methods

__init__([method])

fit(logits, labels)

Fit Beta calibration on binary classification data.

load(path)

Load a calibrator from a file.

load_state_dict(state)

Load Beta calibrator state.

predict(logits)

Get calibrated predictions.

save(path)

Save calibrator state to a file.

state_dict()

Save Beta calibrator state.

__init__(method='mle')[source]#
Parameters:

method (str)

fit(logits, labels)[source]#

Fit Beta calibration on binary classification data. Falls back to isotonic regression for multiclass.

Parameters:
  • logits (Tensor) – Validation logits (N, 2) or (N, C) for multiclass

  • labels (Tensor) – Binary labels (N,)

predict(logits)[source]#

Get calibrated predictions.

Parameters:

logits (Tensor)

Return type:

Categorical

state_dict()[source]#

Save Beta calibrator state.

Return type:

dict

load_state_dict(state)[source]#

Load Beta calibrator state.

Parameters:

state (dict)

Return type:

None