Skip to main content

Interpretable Boosted Linear Models: GLM + XGBoost ensemble with SHAP-based interpretability

Reason this release was yanked:

bad version

Project description

pyIBLM

Interpretable Boosted Linear Models

PyPI version Python versions License: MIT Downloads


Overview

pyIBLM implements Interpretable Boosted Linear Models — a hybrid modelling approach that combines the transparency of Generalized Linear Models (GLMs) with the predictive power of gradient boosting.

The model is a two-stage ensemble:

  1. A GLM is fitted on the training data, producing interpretable coefficient estimates.
  2. An XGBoost booster is trained on the GLM residuals, using the GLM's linear predictor as its base margin — learning only what the GLM could not capture.

Depending on the link function, the two components are combined as:

  • Multiplicative (log-link families: Poisson, Gamma, Tweedie): prediction = GLM prediction × Booster correction
  • Additive (identity-link families: Gaussian): prediction = GLM prediction + Booster correction

SHAP values decompose the booster correction back onto the original GLM feature scale, making the full model auditable and interpretable at the individual prediction level.

The package provides:

  • Fitting of IBLM models across Poisson, Quasi-Poisson, Gamma, Tweedie, and Gaussian families
  • SHAP-based explainability tools with beta coefficient visualisations
  • Model comparison via pinball scores and correction corridor plots
  • Bundled insurance pricing datasets (freMTPLmini, freMTPL2freq)

An equivalent R package is available on CRAN: 🔗 https://CRAN.R-project.org/package=IBLM


Installation

Install the released version from PyPI:

pip install pyiblm

To use load_freMTPL2freq() (downloads the full French MTPL dataset), install with the optional data dependency:

pip install "pyiblm[data]"

Quick start

import numpy as np
from iblm import (
    load_freMTPLmini,
    split_into_train_validate_test,
    IBLM,
    ExplainIBLM,
    get_pinball_scores,
)

# Load and prepare data
df = load_freMTPLmini()
df["LogExposure"] = np.log(df["Exposure"])
df = df.drop(columns=["Exposure"])

df_dict = split_into_train_validate_test(df, seed=9000)

# Fit model
model = IBLM()
model.fit(
    df_dict,
    response_var="ClaimNb",
    offset_var="LogExposure",
    family="poisson",
)

# Evaluate
scores = get_pinball_scores(df_dict["test"], model)
print(scores)

# Explain
ex = ExplainIBLM(model, df_dict["test"])
fig = ex.beta_corrected_scatter("DrivAge", color="VehPower")
fig.show()

Documentation

For full documentation on the R implementation (functions, methods and theoretical background):

🔗 https://ifoa-adswp.github.io/IBLM/


Contributing

Contributions are welcome. To report a bug or suggest a feature, please open an issue on GitHub:

🔗 https://github.com/IFoA-ADSWP/pyIBLM/issues


Citation

If you use pyIBLM in research or teaching, please cite it as:

Gawlowski, K. and Beard, P. (2026). pyIBLM: Interpretable Boosted Linear Models. Python package version 2.0.1.


Authors


License

This package is licensed under the MIT License. See the LICENSE file for full details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyiblm-2.0.1.tar.gz (143.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyiblm-2.0.1-py3-none-any.whl (148.1 kB view details)

Uploaded Python 3

File details

Details for the file pyiblm-2.0.1.tar.gz.

File metadata

  • Download URL: pyiblm-2.0.1.tar.gz
  • Upload date:
  • Size: 143.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for pyiblm-2.0.1.tar.gz
Algorithm Hash digest
SHA256 fb28ac0662a7d2bb725bb284a7629a21c2f2c0301f198e61ada8f8355bf40129
MD5 128a9856dddc2df2a3cac52ca2420ec2
BLAKE2b-256 8e7d0c58307da1a9e0ef4f8c1b0b1e6925f052ffa93c601be07584c25968c010

See more details on using hashes here.

File details

Details for the file pyiblm-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyiblm-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 148.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for pyiblm-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5efbc0e54633043473e6bb25e39ee381ca9175f985139ddf178d705eca69ebff
MD5 d4bd52f92321df2d8178b3962ae1a811
BLAKE2b-256 e0388886720555b7814839f8d9232271989e5238eed0d49c294f1b79dbf47940

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page