Calibration
Hosmer–Lemeshow test
Implemented
calibration.hosmer_lemeshowDefinition
Goodness-of-fit test comparing observed and expected event counts across risk groups.
Formula
H = Σ_g (O_g − E_g)² / (E_g (1 − E_g / n_g)), df = G − 2
Inputs and outputs
- y_true: array of binary labels {0, 1}
- y_prob: predicted probability of the positive class in [0, 1]
- n_groups (default 10)
Returns: statistic, degrees_of_freedom, p_value, n_groups
Assumptions
No assumptions beyond valid, aligned inputs of the documented types.
Limitations
- Results depend on the grouping.
- Low power in small samples and near-certain rejection in very large samples.
- A non-significant result does not show that calibration is good.
Python API
import evalsuite as es
es.hosmer_lemeshow(y_true, y_prob, n_groups=10)References
- Hosmer, D. W., & Lemeshow, S. (1980). Goodness of fit tests for the multiple logistic regression model. Communications in Statistics – Theory and Methods, 9(10), 1035–1049.