incerto.calibration.BetaCalibrator#

class incerto.calibration.BetaCalibrator[source]#

Bases: BaseCalibrator

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

Fits a three-parameter model: logit(q) = a*log(p) + b*log(1-p) + c, where p is the uncalibrated probability and q is the calibrated probability. This is equivalent to assuming the scores for each class follow Beta distributions with different parameters.

Reference:

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

__init__()[source]#

Methods

__init__()

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__()[source]#
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