dirichlet_calibration

probly.method.calibration.dirichlet_calibration(base: Predictor[In, Out], num_classes: int | None = None, reg_lambda: float = 0.001, reg_mu: float | None = None) → CalibrationPredictor[In, Out][source]

Dirichlet-calibrate a multi-class logit classifier based on [KPerelloNKangsepp+19].

Dirichlet calibration fits a multinomial logistic regression on the log-probabilities of the base classifier, q = softmax(W @ ln(p) + b) with a full num_classes x num_classes weight matrix W and bias b. This generalises temperature scaling (and beta calibration for two classes) and recalibrates probabilities rather than logits, which distinguishes it from matrix and vector scaling.

The returned predictor still needs its parameters fitted on a held-out calibration split via probly.calibrator.calibrate() (or the wrapper’s calibrate/fit methods) before it can be used for prediction.

Parameters:
  • base – Base logit classifier to be calibrated.

  • num_classes – Number of classes k the classifier predicts. Must be greater than one and match the class axis of the logits.

  • reg_lambda – Strength of the Off-Diagonal Regularisation, an L2 penalty on the off-diagonal entries of W. 0 disables it, recovering the unregularised full-matrix fit.

  • reg_mu – Strength of the Intercept Regularisation, an L2 penalty on the bias b. Defaults to reg_lambda when None, following the reference implementation; the paper tunes the two strengths separately.

Returns:

The Dirichlet calibration predictor, awaiting calibration.

Examples using probly.method.calibration.dirichlet_calibration

Dirichlet Calibration on MNIST

Dirichlet Calibration on MNIST