Utilities#

Utilities contains example datasets and extra functionality to facilitate a reserving workflow.

Sample Datasets#

A variety of datasets can be loaded using load_sample(). These are sample datasets that are used throughout the examples in this documentation. The full list is available through list_samples(), which returns a table of every bundled dataset along with its index, columns, and grain.

import chainladder as cl

cl.list_samples()
index columns cumulative origin_grain development_grain origin_periods development_periods
name
abc None [values] True Annual Annual 11 11
auto [lob] [incurred, paid] True Annual Annual 10 10
berqsherm [LOB] [Incurred, Paid, Reported, Closed] True Annual Annual 8 8
cc_sample None [loss, exposure] True Annual Annual 5 5
clrd [GRNAME, LOB] [IncurLoss, CumPaidLoss, BulkLoss, EarnedPremD... True Annual Annual 10 10
clrd2025 [GRNAME, LOB] [IncurredLosses, CumPaidLoss, BulkLoss, Earned... True Annual Annual 19 19
friedland_auto_bi_insurer None [Paid Claims, Reported Claims, Earned Premium] True Annual Annual 9 9
friedland_auto_freq_sev None [Closed Claim Counts, Reported Claim Counts, R... True Semiannual Semiannual 10 10
friedland_auto_salsub None [Reported Salvage and Subrogation, Received Sa... True Annual Annual 11 11
friedland_autoprop None [Reported ALAE, Paid ALAE, Reported Claims, Pa... True Annual Annual 11 11
friedland_berq_sher_auto None [Paid Claims, Closed Claim Counts, Reported Cl... True Annual Annual 8 8
friedland_gl_insurer None [Closed Claim Counts, Reported Claim Counts, D... True Annual Annual 8 8
friedland_gl_self_insurer None [Reported Claims, Paid Claims] True Annual Month 11 1
friedland_med_mal None [Reported Claims, Paid Claims, Case Outstandin... True Annual Annual 8 8
friedland_qs None [Gross Reported Claims, Net Reported Claims, N... True Annual Annual 4 4
friedland_us_auto_chg_prod_mix None [Paid Claims, Reported Claims] True Annual Annual 10 10
friedland_us_auto_incr_claim None [Paid Claims, Reported Claims] True Annual Annual 10 10
friedland_us_auto_steady_state None [Paid Claims, Reported Claims] True Annual Annual 10 10
friedland_us_industry_auto None [Paid Claims, Reported Claims, Earned Premium] True Annual Annual 10 10
friedland_us_industry_auto_case None [Case Outstanding, Paid Claims] True Annual Annual 10 10
friedland_uspp_auto_increasing_case None [Reported Claims, Paid Claims, Earned Premium] True Annual Annual 10 10
friedland_uspp_auto_increasing_claim None [Reported Claims, Paid Claims, Earned Premium] True Annual Annual 10 10
friedland_uspp_auto_steady_state None [Reported Claims, Paid Claims, Earned Premium] True Annual Annual 10 10
friedland_uspp_increasing_claim_case None [Reported Claims, Paid Claims, Earned Premium] True Annual Annual 10 10
friedland_wc_self_insurer None [Closed Claim Counts, Reported Claim Counts, P... True Annual Annual 8 8
friedland_xol None [Gross Reported Claims, Net Reported Claims, C... True Annual Annual 4 4
friedland_xyz_auto_bi None [Paid Claims, Reported Claims, Closed Claim Co... True Annual Annual 11 11
friedland_xyz_disp None [Disposal Rate, Closed Claim Counts, Paid Claims] True Annual Annual 8 8
genins None [values] True Annual Annual 10 10
ia_sample None [loss, exposure] True Annual Annual 6 6
liab [lob] [values] True Annual Annual 14 14
m3ir5 None [values] True Annual Annual 14 14
mack_1997 None [Case Incurred] True Annual Annual 10 10
mcl None [incurred, paid] True Annual Annual 7 7
mortgage None [values] True Annual Annual 9 9
mw2008 None [values] True Annual Annual 9 9
mw2014 None [values] True Annual Annual 17 17
prism [ClaimNo, Line, Type, ClaimLiability, Limit, D... [reportedCount, closedPaidCount, Paid, Incurred] False Month Month 120 120
quarterly None [incurred, paid] True Annual Quarter 12 45
raa None [values] True Annual Annual 10 10
tail_sample None [incurred, paid] True Annual Annual 10 10
ukmotor None [values] True Annual Annual 7 7
usaa None [incurred, paid] True Annual Annual 10 10
usauto None [incurred, paid] True Annual Annual 10 10
xyz None [Incurred, Paid, Reported, Closed, Premium] True Annual Annual 11 11

Model Diagnostics#

model_diagnostics() summarizes a fitted IBNR model into a single Triangle whose columns are the diagnostic vectors of interest, such as the latest diagonal, IBNR, and ultimate. It accepts a fitted estimator or a Pipeline, and an optional groupby to summarize at a coarser index level.

model = cl.Chainladder().fit(cl.load_sample('raa'))
cl.model_diagnostics(model)
Triangle Summary
Valuation: 1990-12
Grain: OYDY
Shape: (1, 8, 10, 1)
Index: [Measure, Model, Total]
Columns: [Latest, Quarter Incremental, Year Incremental, LDF, CDF, Ultimate, IBNR, Run Off 1]

Chainladder Persistence#

All estimators can be persisted to disk or database using to_json or to_pickle. Restoring the estimator is as simple as cl.read_json or cl.read_pickle.

import chainladder as cl
model_json = cl.Chainladder().fit(cl.load_sample('raa')).to_json()
model_json
'{"params": {}, "__class__": "Chainladder"}'
cl.read_json(model_json)
Chainladder()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.

The saved Estimator does not retain any fitted attributes, nor does it retain the data on which it was fit. It is simply the model definition. However, the Triangle itself can also be saved allowing for a full rehydration of the original model.

# Dumping triangle to JSON
triangle_json = cl.load_sample('raa').to_json()

# Recalling model and Triangle and rehydrating the results
cl.read_json(model_json).fit(cl.read_json(triangle_json)).ibnr_.sum('origin')
np.float64(52135.228261210155)

Warning

Some features of estimators may not be json-serializable, such as a virtual_column or a callable hyperparameter. In these cases, JSON serialization will fail.