lift_chart#

superglm.lift_chart(
y_obs,
y_pred,
sample_weight=None,
exposure=None,
*,
n_bins: int = 10,
ax: Axes | None = None,
) → LiftChartResult#

Lift chart: observed vs predicted across equal-exposure quantile bins.

Parameters:
y_obsarray-like

Observed response values.

y_predarray-like

Predicted response values.

sample_weightarray-like or None

Observation weights for aggregation.

exposurearray-like or None

Exposure measure for rate models. When provided, bins are equal-exposure quantiles and averages are exposure-weighted.

n_binsint

Number of quantile bins. Rows with equal predictions share a bin, placed by the middle of their exposure, so tied predictions give uneven bins; bins left empty are omitted. When the weights are integers, the exposures are integers or one value shared by every row, and n_bins times the total binned mass is below 2**52, a frequency weight bins exactly as its literal copies. With other fractional exposures, a prediction whose exposure middle lies on a bin edge to within rounding takes the side its float64 sums give, so a weighted row and its literal copies, summed differently, can then sit in neighbouring bins.

axmatplotlib Axes or None

If provided, plot onto this axes (figure in result will be None).

Returns:
LiftChartResult

Contains a bins DataFrame and an optional figure.