Calibrator#

class mlquantify.calibration.Calibrator[source]#

Base class for calibrators.

A calibrator learns a post-hoc transformation of a model’s outputs from a labelled held-out set with fit, then applies it to new outputs with predict. Subclasses implement both methods.

Notes

The argument order follows scikit-learn: fit takes the ground-truth labels first and the model output second – fit(y_true, y_pred).

Examples

>>> from mlquantify.calibration import Calibrator
>>> class IdentityCalibrator(Calibrator):
...     def fit(self, y_true, y_pred):
...         return self
...     def predict(self, y_pred):
...         return y_pred
fit(y_true, y_pred)[source]#

Fit the calibration map from held-out labels and predictions.

fit_predict(y_true, y_pred)[source]#

Convenience: fit(y_true, y_pred) then predict(y_pred).

predict(y_pred)[source]#

Apply the fitted calibration map to new predictions.