pyIBLM
Interpretable Boosted Linear Models
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:
- A GLM is fitted on the training data, producing interpretable coefficient estimates.
- 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
- Karol Gawlowski — kg.actuarial@gmail.com
- Paul Beard — paul.beard.actuarial@gmail.com Additional contributions by Zhouwen Zhou.
License
This package is licensed under the MIT License.
See the LICENSE file for full details.
Metadata
Release files for pyiblm 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyiblm-2.0.2.tar.gz | 367.2 kB | Without provenance | Details for pyiblm-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyiblm-2.0.2-py3-none-any.whl | Python 3 | none | any | Details for pyiblm-2.0.2-py3-none-any.whl |
Total release size: 546.7 kB
Release files / pyiblm-2.0.2.tar.gz
| Download URL | pyiblm-2.0.2.tar.gz |
|---|---|
| Size | 367.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b03c5ea8872a6ff25d6e793151ff8882c0369f98cee22b84e297a04cbbe7d27
|
|
BLAKE2b-256 checksum How to use checksums |
404bf3729aef8179d3a29bca88108b93d7e35d356c030a1727b60e4d92895606
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / pyiblm-2.0.2-py3-none-any.whl
| Download URL | pyiblm-2.0.2-py3-none-any.whl |
|---|---|
| Size | 179.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea20ac05cd64224a83db8f412736a6b0c0052ae19cb5d4859709baaa6daacf9d
|
|
BLAKE2b-256 checksum How to use checksums |
45fb5b93edf298a739d8ae1773163472778a019dfb62769c3a6ca43a377ead53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for pyiblm 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.