Burning Cost is on the forefront of machine learning and data science research in UK personal lines insurance. These libraries are the practical output of that research — each one solving a specific problem in the pricing workflow, built to run on Databricks, tested against actuarial standards. All 50 libraries are on PyPI and MIT-licensed (PyPI pending for insurance-fairness-ot).
The 10 most useful notebooks are collected in the Databricks Notebook Archive. Download the full set as a zip and import directly into Databricks — no cluster setup needed beyond the %pip install in the first cell.
Data & Validation
insurance-datasets
Synthetic UK motor data with a known data-generating process, for testing pricing pipelines and teaching without touching real customer data.
uv add insurance-datasets
insurance-cv
Temporal walk-forward cross-validation with IBNR buffers and sklearn-compatible scorers. Standard k-fold cross-validation gives you optimistic estimates on insurance data because it leaks future claims into training.
uv add insurance-cv
→ Why your cross-validation is lying to you
insurance-synthetic
Vine copula synthetic portfolio generation that preserves the multivariate dependence structure of your actual book, for scenario testing and model benchmarking.
uv add insurance-synthetic
→ Generating realistic synthetic insurance portfolios
insurance-whittaker
Whittaker-Henderson smoothing for experience rating tables. 1D, 2D, and Poisson variants with REML/GCV/AIC lambda selection and Bayesian confidence intervals. Borrows strength from neighbours to smooth noisy age curves, NCD scales, and vehicle group relativities. Pure NumPy/SciPy.
uv add insurance-whittaker
→ Whittaker-Henderson smoothing for insurance pricing
Model Building
insurance-trend
Loss cost trend analysis with structural break detection. Frequency/severity/loss cost fitters, ONS API integration for index deflation, superimposed inflation decomposition, and 1,000-replicate bootstrap confidence intervals. Regime-aware trend selection with ruptures.
uv add insurance-trend
→ Trend selection is not actuarial judgment
insurance-gas
GAS (Generalised Autoregressive Score) models for dynamic insurance pricing — the first maintained Python implementation. Exposure-weighted Poisson frequency, Gamma/log-normal severity, Beta loss ratio, and negative binomial variants. GAS(1,1) MLE via L-BFGS-B, trend_index in the development factor format, panel data across rating cells, and formal diagnostics (PIT, Ljung-Box). Sits between changepoint detection and static trend projection: continuous adaptive estimation updated at each period.
uv add insurance-gas
→ Your Trend Estimate Has No Likelihood
shap-relativities
Multiplicative rating factor tables from CatBoost models via SHAP, in the same format as exp(beta) from a GLM. Exports to Excel and Radar-compatible CSV.
uv add shap-relativities
→ Extracting rating relativities from GBMs with SHAP
insurance-interactions
Automated interaction detection using CANN, NID, and SHAP-based methods. Finds the interaction effects your GLM missed and quantifies their materiality.
uv add insurance-interactions
→ Finding the interactions your GLM missed
insurance-glm-cluster
GLM factor level clustering via R2VF (Ben Dror, arXiv:2503.01521). Collapses high-cardinality categoricals — 500 vehicle makes to 20 pricing bands, 350 occupation codes to 30 groups — using ridge-regularised ranking followed by fused lasso fusion. BIC lambda selection, min-exposure enforcement, monotonicity constraints. Poisson, Gamma, Tweedie with log(exposure) offset.
uv add insurance-glm-cluster
→ 500 Vehicle Makes, One Afternoon, Zero Reproducibility
insurance-anam
Actuarial neural additive model in PyTorch: interpretable deep learning for pricing with per-feature shape functions a pricing committee can inspect.
uv add insurance-anam
→ Your interpretable model isn’t interpretable enough
insurance-ebm
Insurance workflow layer on top of interpretML’s ExplainableBoostingMachine. RelativitiesTable, MonotonicityEditor, GLMComparison, and actuarial diagnostics (Gini, double-lift, calibration). EBMs are GAMs fitted by gradient boosting - the shape functions are the model, not a post-hoc summary.
uv add insurance-ebm[interpret]
→ EBMs for insurance pricing
bayesian-pricing
Hierarchical Bayesian models for thin-data pricing segments using PyMC 5. When a segment has 200 policies and 3 claims, full posterior inference tells you more than a point estimate.
uv add bayesian-pricing
→ Bayesian hierarchical models for thin-data pricing
insurance-multilevel
CatBoost combined with REML random effects for high-cardinality categorical groups such as brokers and schemes. Partial pooling without leaving the gradient boosting framework.
uv add insurance-multilevel
→ Your broker adjustments are guesswork
credibility
Buhlmann-Straub credibility in Python with mixed-model equivalence checks. Includes NCD factor stabilisation and blending a new model with incumbent rates in thin cells.
uv add credibility
→ Buhlmann-Straub credibility in Python
experience-rating
NCD and bonus-malus systems for UK motor insurance. NCD as a Markov chain, stationary distributions, and the non-obvious claiming threshold result: optimal thresholds peak at 20% NCD, not 65%.
uv add experience-rating
→ Experience rating: NCD and bonus-malus systems
insurance-experience
Individual policy-level Bayesian posterior experience rating. Four model tiers: static Bühlmann-Straub, dynamic Poisson-gamma state-space with seniority weighting (Ahn/Jeong/Lu/Wüthrich 2023), IS-based surrogate Bayesian posteriors for non-conjugate models (Calcetero/Badescu/Lin 2024), and deep attention credibility (Wüthrich 2024). All four produce a multiplicative credibility factor; the balance property holds at portfolio level.
uv add insurance-experience
→ Individual Experience Rating Beyond NCD: From Bühlmann-Straub to Neural Credibility
insurance-credibility-transformer
Credibility Transformer — CLS token attention as Bühlmann-Straub credibility, ICL zero-shot pricing, base/deep/ICL variants (85 tests). The CLS token’s self-attention weight IS the credibility weight — mathematically identical to Bühlmann-Straub, not an analogy. 1,746 parameters, beats CAFTT (27K parameters). ICL extension enables zero-shot pricing for unseen categorical levels (new vehicle models, new regions) without retraining.
pip install insurance-credibility-transformer
→ The Attention Head That Is Also a Credibility Weight
Interpretation & Risk
insurance-conformal
Distribution-free prediction intervals with finite-sample coverage guarantees. v0.2 adds locally-weighted intervals (~24% narrower, CatBoost spread model), model-free conformal (Hong 2025, no point predictor needed), SCRReport for Solvency II 99.5% upper bounds with multi-alpha coverage validation tables, and ERT diagnostics for conditional coverage by rating segment. 186 tests.
uv add "insurance-conformal[catboost]"
→ Distribution-free solvency capital from conformal prediction · Why your prediction intervals are lying to you
insurance-conformal-fraud
Conformal p-values for claims fraud detection with provable FDR-controlled SIU referral. Wraps any sklearn anomaly detector. Mondrian stratification by claim type (TPBI, AD, Theft), integrative conformal from SIU case files (Lemos et al. 2024, JRSS-B), Fisher combination for IFB consortium detection without sharing claim data. 133 tests.
pip install insurance-conformal-fraud
→ Your SIU Referral Threshold Is Arbitrary. Here Is How to Fix It.
insurance-quantile
Quantile and expectile GBMs for tail risk, TVaR, and increased limit factors. When the mean is not the right risk measure.
uv add insurance-quantile
→ Quantile GBMs for insurance tail risk
insurance-distributional
Distributional GBMs with Tweedie, Gamma, ZIP, and negative binomial objectives. Fit the full conditional distribution, not just the conditional mean.
uv add insurance-distributional
→ Distributional GBMs for insurance pricing
insurance-drn
Distributional Refinement Networks for insurance pricing. Wraps any GLM or GBM baseline with a neural network that refines the predictive distribution bin by bin, per covariate. Vectorised CDF, quantile, CRPS, and Expected Shortfall. JBCE loss. PyTorch. Preserves GLM calibration exactly when the network has nothing useful to add.
uv add insurance-drn
→ GLMs Predict Means. DRN Predicts Everything Else.
insurance-distributional-glm
GAMLSS (Generalised Additive Models for Location, Scale and Shape) for Python. Model ALL distribution parameters as functions of covariates — mean, dispersion, shape, zero-inflation probability. Seven families: Gamma, LogNormal, InverseGaussian, Tweedie, Poisson, NegativeBinomial, ZIP. RS algorithm with backtracking. Pure NumPy/SciPy.
uv add insurance-distributional-glm
→ GAMLSS in Python, finally
insurance-dispersion
Double GLM (DGLM) for joint modelling of mean AND dispersion in insurance pricing. Every observation gets its own phi_i — enabling risk-adequate margin loading, Solvency II variance at policy level, and Tweedie segments with independent frequency-severity movement. Six families, REML correction, overdispersion LRT, factor tables. Pure NumPy/SciPy.
uv add insurance-dispersion
→ Double GLM for Insurance: Every Risk Gets Its Own Dispersion
insurance-ilf
Increased limits factor curves from severity distributions. Mixed Exponential, Lognormal-Pareto, and empirical methods with bootstrap confidence intervals. For pricing layers and excess-of-loss attachments.
uv add insurance-ilf
insurance-sensitivity
Shapley effects for rating factor variance decomposition. Which rating factor drives the most premium variance in your book? Song et al. (2016) random permutation estimator with Rabitti-Tzougas (2025) CLH subsampling for large datasets, exposure-weighted variance throughout, and a fitted-model interface that accepts any GLM or GBM. 112 tests.
uv add insurance-sensitivity
→ Shapley Effects for Rating Factor Variance Decomposition
insurance-composite
Composite severity regression — spliced body/tail distributions with covariate-dependent thresholds, ILF estimation, and TVaR. The body and tail of a severity distribution obey different physics; this fits them separately while letting the threshold vary by covariate. 106 tests.
uv add insurance-composite
→ Composite Severity Regression: Fitting Body and Tail Separately
insurance-evt
Extreme Value Theory for catastrophic claim severity. GPD fitting with censored MLE for open TPBI claims (Poudyal & Brazauskas 2023), profile likelihood confidence intervals, return levels for Solvency II SCR, and the first Python implementation of ExcessGPD for XL layer pure premium pricing. GEV for block maxima (subsidence, portfolio catastrophe). Five UK peril presets: TPBI, flood, subsidence, large fire, storm.
uv add insurance-evt
→ Extreme Value Theory for UK Motor Large Loss Pricing
Causal Inference
insurance-causal
Causal inference via double machine learning for deconfounding rating factors. Separates the causal effect of a rating factor from the confounding driven by correlated features.
uv add insurance-causal
→ Causal inference for insurance pricing
insurance-elasticity
Causal price elasticity estimation via CausalForestDML and DR-Learner. Heterogeneous treatment effects on conversion and retention, corrected for selection bias.
uv add insurance-elasticity
→ Your rating factor might be confounded
insurance-causal-policy
Synthetic difference-in-differences for causal rate change evaluation. Produces the counterfactual portfolio and FCA evidence pack you need to demonstrate a rate change worked.
uv add insurance-causal-policy
→ Your rate change didn’t prove anything
insurance-counterfactual-sets
Lei & Candès 2021 weighted conformal inference for individual ENBP counterfactual prediction sets. Finite-sample valid harm assessment at the policyholder level: for each renewing customer, constructs a prediction set for their claims under new-business pricing. FCA EP25/2 attestation pack output. CQR variant for heteroskedastic claims. Jin, Ren & Candès 2023 (PNAS) sensitivity analysis with per-policyholder Gamma values.
pip install insurance-counterfactual-sets
→ The ENBP Counterfactual Problem Has a Statistical Answer
insurance-demand
Conversion, retention, and DML price elasticity modelling integrated with rate optimisation. Demand curves feed directly into constrained optimisation.
uv add insurance-demand
→ Demand modelling for insurance pricing
insurance-uplift
Uplift modelling for UK personal lines retention targeting. Estimates per-customer treatment effects (CATE) on renewal probability via CausalForestDML, classifies the portfolio into Persuadables, Sure Things, Lost Causes, and Do Not Disturbs (Guelman et al.), evaluates with Qini curves and AUUC, builds optimal targeting rules via PolicyTree, clips recommendations to ENBP (ICOBS 6B.2), and audits CATE distribution across vulnerability proxies for Consumer Duty. 127 tests.
uv add insurance-uplift
→ Your Retention Campaign Has No Targeting Rule
—
Optimisation
rate-optimiser
Constrained rate change optimisation with an efficient frontier between loss ratio target and movement cap constraints. Linear programming formulation with shadow price reporting and FCA GIPP (PS21/5) constraints.
uv add rate-optimiser
→ Constrained rate optimisation and the efficient frontier
insurance-optimise
SLSQP portfolio rate optimisation with analytical Jacobians for large factor spaces. When the number of factors makes linear programming too slow.
uv add insurance-optimise
→ Portfolio rate optimisation with insurance-optimise
insurance-dro
Distributionally robust rate optimisation using Wasserstein ambiguity sets. Instead of optimising against a point-estimate demand model, optimises against the worst-case distribution within a calibrated ball around your empirical samples. Produces a price-of-robustness curve for pricing committee papers. CVXPY + CLARABEL backend, FCA ENBP as hard constraint, 137 tests.
pip install insurance-dro
→ Your Rate Optimiser Has No Safety Margin
Compliance & Governance
insurance-fairness
Proxy discrimination auditing and FCA Consumer Duty documentation support. Quantifies indirect discrimination risk through protected characteristic proxies in rating factors.
uv add insurance-fairness
→ Your pricing model might be discriminating
insurance-fairness-ot
Optimal transport discrimination-free pricing. Computes corrected premiums via Lindholm (2022) marginalisation, Côté-Genest-Abdallah (2025) causal path decomposition, and Wasserstein barycenter for the multi-attribute case. Built for FCA EP25/2 compliance and the Equality Act Section 19 proportionate justification test. PyPI pending.
uv add insurance-fairness-ot
→ Discrimination-Free Pricing with Optimal Transport
insurance-fairness-diag
Proxy discrimination diagnostics. Quantifies how much proxy discrimination a fitted model contains (D_proxy scalar, LRTW 2026) and which rating factors are responsible (Owen 2014 Shapley effects). Per-policyholder vulnerability scores (Côté-Charpentier 2025). HTML/JSON audit reports for FCA EP25/2 and Consumer Duty evidence. The diagnostic layer before you decide whether to correct.
uv add insurance-fairness-diag
→ Your Pricing Model Is Discriminating. Here’s Which Factor Is Doing It.
insurance-validation
Structured PRA SS1/23 model validation reports covering nine required sections, output as HTML and JSON. Designed around the actual regulatory standard, not a generic model card.
uv add insurance-validation
→ Model validation reports for PRA SS1/23
insurance-calibration
Balance property testing, auto-calibration curves, Murphy score decomposition. Detect and correct systematic bias in predicted frequencies and severities before deployment.
uv add insurance-calibration
insurance-monitoring
Exposure-weighted PSI/CSI, actual-vs-expected ratios, and Gini drift z-tests for deployed models. Scheduled monitoring with alert thresholds, not one-off validation.
uv add insurance-monitoring
→ Your pricing model is drifting
insurance-mrm
Model risk management: ModelCard, ModelInventory, and GovernanceReport generation. Replaces the spreadsheet model risk register with a structured, versioned artefact.
uv add insurance-mrm
→ Your model risk register is a spreadsheet
insurance-deploy
Champion/challenger framework with shadow mode, rollback, and full audit trail. Structured deployment for pricing models that need a sign-off process.
uv add insurance-deploy
→ Your champion/challenger test has no audit trail
insurance-bunching
Bunching estimators for threshold gaming detection. Adapted from public economics (Saez 2010; Kleven 2016) to detect mileage declaration fraud, adverse deductible selection, sum-insured rounding, and age misreporting. BH FDR-controlled multi-threshold scanning. Self-contained HTML reports for FCA Consumer Duty evidence. First Python bunching estimator in any field.
uv add insurance-bunching
→ Detecting Threshold Gaming in Insurance Portfolios
Spatial
insurance-spatial
BYM2 spatial models for postcode-level territory ratemaking, borrowing strength from neighbouring areas. Handles the sparse-data problem in granular geographic segmentation.
uv add insurance-spatial
→ Spatial territory ratemaking with BYM2
insurance-nested-glm
Nested GLM with neural network entity embeddings for high-cardinality categoricals (vehicle make/model, postcode sector) and spatially constrained territory clustering via SKATER. The final model is a standard interpretable GLM with multiplicative relativities. Based on Wang, Shi, Cao (NAAJ 2025).
uv add insurance-nested-glm
Telematics
insurance-telematics
End-to-end pipeline from raw 1Hz GPS/accelerometer data to GLM-compatible risk scores. TripSimulator generates synthetic fleets (Ornstein-Uhlenbeck speed processes, Dirichlet regime mixtures) so teams without raw data can build and test immediately. DrivingStateHMM and ContinuousTimeHMM classify driving into cautious/normal/aggressive states. Bühlmann-Straub credibility aggregation to driver level. Poisson GLM pipeline.
uv add insurance-telematics
→ HMM-Based Telematics Risk Scoring for Insurance Pricing
Retention
insurance-survival
Cure models, customer lifetime value, lapse tables, and MLflow wrapper for retention modelling. Treats lapse as a competing risk rather than a binary outcome.
uv add insurance-survival
→ Survival models for insurance retention
insurance-cure
Mixture cure models for insurance non-claimer scoring. Separates structurally immune policyholders from susceptibles using a two-component mixture: logistic incidence sub-model (cure fraction) and survival latency (time-to-claim for susceptibles). WeibullMCM, LogNormalMCM, and CoxMCM for parametric and semiparametric latency. Maller-Zhou Qn test for sufficient follow-up before fitting. CureScorecard decile validation. First Python implementation with covariate-aware MCMs. 158 tests.
uv add insurance-cure
→ Separating Structural Non-Claimers from Risk: Mixture Cure Models for Insurance Pricing
insurance-uplift
HTE uplift modelling for retention. CausalForestDML heterogeneous treatment effects identify which customers are genuinely persuadable — positive responders — rather than treating the whole book as equally retention-sensitive. Qini coefficient and AUUC for model evaluation, four-quadrant customer taxonomy (persuadables, sure things, lost causes, sleeping dogs), PolicyTree for interpretable uplift rules, expected net benefit per policyholder (ENBP) profit constraint, and a Consumer Duty fairness audit checking that retention effort does not disadvantage vulnerable customers. 127 tests.
uv add insurance-uplift
→ Uplift Modelling for Insurance Retention: Finding Who to Save
Pricing / Reserving Bridge
insurance-nowcast
ML-EM nowcasting for claims reporting delays. The last 6–24 months of your accident year data is partially developed. Standard practice applies aggregate development factors from the reserving triangle — factors that do not condition on your actual risk mix. insurance-nowcast implements the Wilsens/Antonio/Claeskens ML-EM algorithm to produce completion factors by risk segment, and nowcasted IBNR counts that a frequency GLM can treat as fully developed data.
uv add insurance-nowcast
→ Your Most Recent Experience Data Is Wrong, and Aggregate Factors Won’t Fix It
insurance-bunching
Bunching estimators for detecting threshold gaming in insurance portfolios. Adapted from public economics (Saez 2010, Kleven 2016) — the first Python implementation for insurance. Detects excess mass at NCD thresholds, deductible boundaries, and sum-insured round numbers. Iterative polynomial counterfactual density, WLS exposure weighting, bootstrap standard errors, kink/notch modes, Benjamini-Hochberg FDR correction for multi-threshold scanning, and Jinja2 HTML/JSON reports.
uv add insurance-bunching
→ Detecting Threshold Gaming in Insurance Portfolios
insurance-changepoint
Bayesian change-point detection for UK insurance pricing time series. Online BOCPD (Adams & MacKay 2007) with exposure-weighted Poisson-Gamma conjugate for claim frequency — no existing Python package handles insurance exposure in BOCPD. PELT with bootstrap CIs for retrospective analysis. Ten UK regulatory event priors (Ogden, COVID, Whiplash Reform, GIPP, storms) encoded as hazard function multipliers. Consumer Duty (PRIN 2A.9) evidence pack generation for FCA compliance.
uv add insurance-changepoint
→ When Did Your Loss Ratio Actually Change?
All libraries are MIT-licensed and available on PyPI and GitHub. Each ships with a Databricks notebook demo and synthetic data. If something is missing from this list, get in touch.
Looking for runnable notebooks? The Databricks Notebook Archive collects 10 curated demos you can import directly.