easy_glm
EasyGLM fits GLMs. It is designed for insurance pricing and turns fitted rating factors into insurance rate tables.
Yes, its been built with AI (insert Boris Johnson sounds)
Install
pip install easy-glm
Open the workbench
Start the graphical workbench:
easy-glm-workbench
It opens EasyGLM in your browser, normally at
http://localhost:8501. Keep this terminal open while you use the workbench.
For a first run without supplying a file, open Project & data and click Use the French motor sample. EasyGLM downloads that sample once and keeps a local copy for later runs.
To reopen a saved project later, pass its project file after the command:
easy-glm-workbench path/to/project.easyglm-project.json
Fit a Poisson claim-count model
We will fit a Poisson claim count model using the good ol' French Motort Third Party claims frequency dataset. The dataset contains ClaimNb for claim count, Exposure for - uh - yeah no guesses there and insurance-y variables like DrivAge, Region, BonusMalus and Density.
As ever, we love a good train/test set. The code creates a traintest column: 70% of rows teach the model; the other 30% are kept for the check at the end.
import easy_glm
# Downloads the public data once and reuses the local copy later.
df = easy_glm.load_external_dataframe().sample(n=50_000, seed=42)
df = easy_glm.add_train_test_split(df, train_fraction=0.7, seed=42)
predictors = ["DrivAge", "Region", "BonusMalus", "Density"]
model = easy_glm.EasyGLM.fit(
data=df,
target="ClaimNb",
model_type="Poisson",
predictors=predictors,
weight_col="Exposure",
train_test_col="traintest",
divide_target_by_weight=True,
cv=5,
)
See the fitted relativity tables
The base claim frequency is the starting level. A relativity of 1.20 means
20% more expected claims than a relativity of 1.00, after taking account of
the other fitted factors. exposure shows how much insured time informed each
row of the table.
print(f"Base claim frequency: {model.base_rate:.5f} claims per policy-year")
for name, table in model.relativities.items():
print(f"\n{name}")
print(table.select("label", "relativity", "exposure"))
The output includes numeric bands and text levels. These are representative rows from the fitted French motor model:
Base claim frequency: 0.04167 claims per policy-year
BonusMalus
band relativity exposure
< 53.0 1.000 12108.31
[53.0, 57.0) 1.355 790.70
[57.0, 60.0) 1.830 694.10
Region
level relativity exposure
Centre 1.000 5218.59
Rhone-Alpes 1.356 2312.63
Provence-Alpes-Cotes-D'Azur 1.177 1835.53
Plot the fitted shapes
Run the following to open the fitted shapes, then the training and test actual-versus-expected rate charts. The validation charts use the exact fitted bands or category order, draw Actual in red and Expected in blue, and show Exposure behind the rate lines.
easy_glm.plot_all_ratetables(model.relativities)
model.plot_actual_vs_expected(df)
The images below were generated by that example. Expected rates use the complete fitted model, not just the factor named on the figure.
The same walkthrough is available as a standalone basic usage example. It uses the same public French motor data loader and local cache.
MIT licensed. See LICENSE.
Release files for easy-glm 0.4.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 | |
|---|---|---|---|
| easy_glm-0.4.2.tar.gz | 395.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easy_glm-0.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 667.5 kB
Release files / easy_glm-0.4.2.tar.gz
| Download URL | easy_glm-0.4.2.tar.gz |
|---|---|
| Size | 395.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04f5792ba2b22fef72c403c391bce2a2b771ff47155ab5256af44566ed0f2e1f
|
|
BLAKE2b-256 checksum How to use checksums |
994308a27256002eabec09a46db92722fdf070a42cf615ead6d345f4e1d7bf02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.
Transparency logRelease files / easy_glm-0.4.2-py3-none-any.whl
| Download URL | easy_glm-0.4.2-py3-none-any.whl |
|---|---|
| Size | 271.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cf0e655eacc85f1cabc4476a75365af9ad3331b94136e4e98f413c4328110fa
|
|
BLAKE2b-256 checksum How to use checksums |
698bb7545f9189cc6fd6be142e6befd5a974b860e7bd7e966997c81d3bed7293
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.
Transparency log