Classical ML, validation, metrics, interpretation, debugging · insight-1172
Model counts per exposure with a log-exposure offset instead of raw counts or an unweighted rate
- Evidence type
- documented fact
- Difficulty
- medium
- Roles
- Data scientist
- Industries
- insurance, manufacturing, aviation
Summary: situation, action, reason, boundary
Situation
Counts of no-shows, claims or defects accrue over very different amounts of exposure: flights flown, policy-years, machine-hours.
Action
Fit a Poisson or negative binomial GLM with a log link and log(exposure) as an offset (the exposure argument in statsmodels), or in scikit-learn model counts divided by exposure with exposure as sample weight. Predict expected counts as rate times exposure.
Reason
With a log link, log(mean) = log(exposure) + X beta, so mean counts scale proportionally and coefficients are rate ratios.
Boundary
Claim frequency, defect and incident counts, any event count with unequal observation windows.
Symptom or risk
Raw counts let exposure leak into coefficients so big units look risky; an unweighted rate gives a 3-flight route the same say as a 3,000-flight route and is undefined at zero exposure.
Exceptions
Identical exposure across rows, where the offset folds into the intercept.
Trade-offs
Assumes risk is proportional to exposure; add log(exposure) as a free covariate when it is not.
Pitfalls
Supplying exposure with a non-log link, which statsmodels does not allow, or adding the same exposure as both offset and ordinary feature without noticing.
Lessons and concepts
Claims and their sources
In statsmodels GLM, exposure adds log(exposure) to the linear predictor with its coefficient fixed at 1 and is valid only with the log link; offset is a term whose coefficient is constrained to 1.
For relative frequencies, scikit-learn suggests a Poisson target of counts divided by exposure with exposure as sample weights.