burncost
Python library for ratemaking-ready loss-experience preparation. Loss development (chain-ladder, Bornhuetter-Ferguson), trend estimation, and premium on-leveling via the parallelogram method. Designed to chain into a downstream rate model.
Installation
pip install burncost
From source:
git clone https://github.com/CosmikArt/burncost.git
cd burncost
pip install -e ".[dev]"
Quickstart
import matplotlib
matplotlib.use("Agg") # headless-safe; remove if you want an interactive window
import numpy as np
import pandas as pd
from burncost import (
LossTriangle,
DevelopmentFactors,
TrendEstimator,
OnLevelPremium,
BurningCostAnalysis,
)
# --- 1. Loss development ---------------------------------------------------
# Cumulative paid-loss triangle (AY x development month)
triangle_data = np.array([
[1_000, 1_500, 1_800, 1_900],
[1_100, 1_650, 1_980, np.nan],
[1_200, 1_800, np.nan, np.nan],
[1_300, np.nan, np.nan, np.nan],
])
accident_years = [2022, 2023, 2024, 2025]
dev_periods = [12, 24, 36, 48]
tri = LossTriangle(triangle_data, accident_years, dev_periods)
dev = DevelopmentFactors.from_triangle(tri)
ata = dev.age_to_age() # age-to-age factors per interval
atu = dev.age_to_ultimate() # cumulative to ultimate
sel = dev.selected_factors() # weighted-average selected factors
tail = dev.tail_factor() # tail beyond last observed period
# --- 2. Trend estimation ---------------------------------------------------
years = np.array([2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025])
severity = np.array([4200, 4400, 4550, 4800, 5100, 5350, 5600, 5900])
trend = TrendEstimator()
trend.fit(years, severity, method="exponential")
annual_trend = trend.trend_factor(from_year=2022, to_year=2026)
projected = trend.predict(np.array([2026, 2027]))
trend.plot()
# --- 3. Premium on-leveling -----------------------------------------------
rate_changes = pd.DataFrame({
"effective_date": pd.to_datetime(["2021-07-01", "2023-01-01", "2024-04-01"]),
"change": [0.05, 0.08, -0.03],
})
onlevel = OnLevelPremium()
onlevel.apply_rate_changes(rate_changes)
olf = onlevel.on_level_factor(policy_year=2022)
# --- 4. End-to-end burning cost pipeline -----------------------------------
bc = BurningCostAnalysis(
triangle=tri,
trend_estimator=trend,
on_level=onlevel,
)
# bc.run() will wire development -> trending -> on-leveling into one table.
# --- 5. Diagnostics --------------------------------------------------------
from burncost.diagnostics import trend_fit_summary, development_stability
print(trend_fit_summary(trend))
print(development_stability(dev))
Modules
The five top-level classes are re-exported from the package root, so
from burncost import X works for all of them. Internally each concern
lives in its own module.
| Module | What's in it |
|---|---|
burncost.triangle |
LossTriangle: incremental/cumulative container with to_cumulative, to_incremental, to_dataframe, latest_diagonal. |
burncost.development |
DevelopmentFactors: age-to-age factors (volume / simple / medial averaging), age-to-ultimate, chain-ladder, Bornhuetter-Ferguson, exponential tail extrapolation. |
burncost.trending |
TrendEstimator: seven trend forms (exponential, linear, multiplicative, additive, power, log-linear, mixed); predict, trend_factor, annual_rate, plot. |
burncost.onlevel |
OnLevelPremium: parallelogram-method on-leveling with rate-change ingestion, vectorised on_level_factors, per-year on_level_factor. |
burncost.pipeline |
BurningCostAnalysis: end-to-end wiring of development, trending, and on-leveling into one output table. |
burncost.diagnostics |
trend_fit_summary, goodness_of_fit, trend_residual_plot, development_stability, development_factor_plot, chain_ladder_residuals (Mack-style). |
References
- Werner, G. & Modlin, C. Basic Ratemaking, CAS, Chapters 4-5 (trending and loss development).
- Mack, T. (1993). "Distribution-free Calculation of the Standard Error of Chain Ladder Reserve Estimates." ASTIN Bulletin, 23(2), 213-225.
- Bornhuetter, R. L. & Ferguson, R. E. (1972). "The Actuary and IBNR." Proceedings of the CAS, LIX, 181-195.
- Friedland, J. Estimating Unpaid Claims Using Basic Techniques. Casualty Actuarial Society.
Contributing
Run pytest before sending a PR.
Author
Isaac López
MIT License. See LICENSE.
Metadata
Release files for burncost 0.1.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 |
|---|---|---|---|---|
| burncost-0.1.2.tar.gz | 25.1 kB | Without provenance | Details for burncost-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| burncost-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for burncost-0.1.2-py3-none-any.whl |
Total release size: 44.1 kB
Release files / burncost-0.1.2.tar.gz
| Download URL | burncost-0.1.2.tar.gz |
|---|---|
| Size | 25.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87649406be81fe61828785b9be76e259d8d9de4722c4a6dce8e6bdca3b6b2069
|
|
BLAKE2b-256 checksum How to use checksums |
263618778b07a1ae4b9e4c904769f22b6857747307cc828923a482bcba79788b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / burncost-0.1.2-py3-none-any.whl
| Download URL | burncost-0.1.2-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf320fc322360935e6232a2fdcc42c23fec1f82d983ef1515089c10a435f2a65
|
|
BLAKE2b-256 checksum How to use checksums |
b935b254bff17b7e359daaea0ea5e887b6644501a6001f5bf3385ec4fb5d457b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for burncost 0.1.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.