Skip to main content

lossmodels

Severity and frequency fitting and aggregate loss distributions.

CI PyPI Python

Overview

lossmodels covers the loss-distribution workflow from data to aggregate: a severity catalog spanning the classic distributions and the transformed beta and transformed gamma families, frequency models, maximum likelihood that is truncation- and censoring-aware, fit diagnostics and model selection, and aggregate distributions via simulation, FFT, and Panjer recursion.

Every severity model shares one interface — moments, quantiles, limited expected values, increased-limits tables — so fitted models drop directly into coverage modifications, aggregates, and the wider ecosystem.

Installation

pip install lossmodels

Requires Python 3.10 or newer.

Quick start

from lossmodels import Poisson, Lognormal, CollectiveRiskModel

freq = Poisson(lam=2.0)
sev = Lognormal(mu=10.0, sigma=0.8)
model = CollectiveRiskModel(freq, sev)

print("Mean     :", model.mean())
print("Variance :", model.variance())
print("VaR 95%  :", model.var(0.95))
print("TVaR 95% :", model.tvar(0.95))

samples = model.sample(50_000, rng=0)
print("Simulated mean:", samples.mean())

What's inside

  • Severity — classic and extended catalogs (including the transformed beta and transformed gamma families) behind one shared interface, plus increased-limits and loss-elimination tables.
  • Frequency — Poisson, negative binomial, and related counting models.
  • Estimation — MLE with truncation and censoring support, parameter uncertainty, goodness-of-fit diagnostics, and model comparison.
  • AggregateCollectiveRiskModel simulation, FFT and Panjer recursion, stop-loss and risk measures.
  • Coverage — deductibles, limits, and coinsurance applied analytically.
  • Empirical — nonparametric counterparts for validation.

The full API reference and end-to-end worked examples live at openactuarial.org/lossmodels.html.

The OpenActuarial ecosystem

lossmodels is one of seven packages that share conventions — tidy tables, explicit distribution parameterizations, reproducible random-number handling — and compose across package seams:

Package Role
actuarialpy Calculation primitives the workflow packages build on
experiencestudies Experience reporting, actual-vs-expected, claimant and concentration analysis
projectionmodels Claim, premium, and expense projection over a renewal horizon
ratingmodels Manual and experience rating, credibility, indication, GLM relativities
lossmodels Severity and frequency fitting, aggregate loss distributions
extremeloss Extreme-value tails: POT/GPD, GEV, return levels, splicing
risksim Portfolio Monte Carlo, dependence, reinsurance contracts, risk measures

Install everything at once with pip install openactuarial.

Development

git clone https://github.com/OpenActuarial/lossmodels
cd lossmodels
python -m pip install -e ".[dev]"
pytest
ruff check src tests

CI runs the same gate on Python 3.10–3.14 across Linux and Windows.

Versioning and stability

All ecosystem packages are pre-1.0: minor releases may change APIs, and every release is documented in CHANGELOG.md. Current per-package API stability is tracked at openactuarial.org/stability.html.

License

MIT — see LICENSE.

Download files

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

Source Distribution

lossmodels-0.8.0.tar.gz (90.8 kB view details)

Uploaded Source

Built Distribution

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

lossmodels-0.8.0-py3-none-any.whl (70.4 kB view details)

Uploaded Python 3

File details

Details for the file lossmodels-0.8.0.tar.gz.

File metadata

  • Download URL: lossmodels-0.8.0.tar.gz
  • Upload date:
  • Size: 90.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lossmodels-0.8.0.tar.gz
Algorithm Hash digest
SHA256 8fb6aefccd6313b760a135d9b0a205e18dac7ed5d311d5b2a869633e73faaebe
MD5 b82c4272170b24af0eced5749777cac4
BLAKE2b-256 f44bfb5452917813e5181551abac0d8c46db52c474f8d1dc51ddaabc4308c6dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for lossmodels-0.8.0.tar.gz:

Publisher: release.yml on OpenActuarial/lossmodels

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lossmodels-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: lossmodels-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 70.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lossmodels-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d76eae714cd8683bb4cc4556d99c9effb3efaa9f585b03bf4613827a44721abf
MD5 5da46dae01880de9479abb9a936cf227
BLAKE2b-256 fdd3c636b63771b3ca6f8201cd600d0fd3716922a5fd0ed5ba5d3adb94238f37

See more details on using hashes here.

Provenance

The following attestation bundles were made for lossmodels-0.8.0-py3-none-any.whl:

Publisher: release.yml on OpenActuarial/lossmodels

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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