dirichlet_calibration¶
- probly.transformation.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 fullnum_classes x num_classesweight matrixWand biasb. 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’scalibrate/fitmethods) before it can be used for prediction.- Parameters:
base – Base logit classifier to be calibrated.
num_classes – Number of classes
kthe 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.0disables it, recovering the unregularised full-matrix fit.reg_mu – Strength of the Intercept Regularisation, an L2 penalty on the bias
b. Defaults toreg_lambdawhenNone, following the reference implementation; the paper tunes the two strengths separately.
- Returns:
The Dirichlet calibration predictor, awaiting calibration.