Machine learning in risk: a logistic regression claim scorer
Interactive logistic regression demo that scores a driver's annual claim probability from age, licence years, prior claims, vehicle value, mileage and urban location, with a feature-contribution chart explaining the score.
Logistic regression is the first model most pricing and underwriting teams reach for when the outcome is yes or no: will this policy claim this year? It passes a weighted sum of rating factors through the sigmoid function to get a probability between 0 and 1, and its coefficients read directly as changes in log-odds, which is why it remains the explainable baseline against which gradient boosting and neural networks are judged.
The scorer takes six driver and vehicle features (age, years licensed, claims in the last three years, vehicle value, annual mileage, and urban or rural driving) and shows the annual claim probability on a gauge: about 5% for the default driver. A contribution chart breaks the score down feature by feature against a fixed baseline driver (age 45, 15 years licensed, no prior claims, a $20,000 car, 10,000 miles a year, rural). Move one slider and watch which factor dominates; that decomposition is what a regulator or underwriter asks for when a model has to be explained.
The coefficients here are set by hand for illustration. They are plausible in direction and size (age enters as a U-shape, so both very young and very old drivers score higher) but are not fitted to any dataset. The next section, credit scoring, fits a model live on synthetic data, so that training, validation and calibration can be seen rather than described.
Logistic regression
p = σ(z) = 1 / (1 + e^{−z}), z = β₀ + β₁x₁ + … + β_k x_k
p is the predicted probability, z the log-odds, β₀ the intercept and x₁ … x_k the features. Each β_j is the change in log-odds per unit of x_j, and exp(β_j) is the corresponding odds ratio.
Frequently asked questions
Why use logistic regression instead of a more powerful model?
Because it is interpretable, stable on small data, and its coefficients map directly to odds ratios that underwriters and regulators understand. More flexible models are often benchmarked against it and used only where the gain in accuracy justifies the loss of explainability.
What does a feature contribution chart show?
The signed change in log-odds attributable to each feature relative to a baseline profile. Red bars raise the claim probability, green bars lower it, and the longest bar names the dominant driver of the score.
Is this model fitted to real data?
No. The coefficients are hand-set to illustrate how the model behaves. A production model would be fitted by maximum likelihood on historical policies and validated on held-out data.
Interactive explorer
The live model with sliders, charts and real-time statistics loads on this page. If it does not appear, enable JavaScript or open https://www.beyondaverages.org/ml-claim-scorer in a modern browser.
Related modules
- Dice & convolution: Interactive 3D dice simulator. Roll up to five dice and watch the empirical sum histogram converge to the exact convolution probabilities: uniform to triangular to bell-shaped, the central limit theorem made visible.
- Cards & hypergeometric: Interactive card-dealing simulator. Deal hands from a 3D deck and compare empirical frequencies of aces, pairs and colors against exact hypergeometric probabilities, and see why a deck's memory matters.
- Frequency: Interactive Poisson distribution explorer for insurance claim counts and hospital admissions. Move the rate λ and watch P(X=k), the mode, and the probability of zero or extreme counts update live.
- Severity: Interactive loss severity explorer comparing Log-Normal, Pareto (heavy-tail) and Gamma distributions. Adjust parameters and see the mean, median, 95th and 99th percentile claim sizes, and the share of total cost from the largest 5% of claims, update in real time.