Utilities#

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

Sample Datasets#

A variety of datasets can be loaded using :func:load_sample(). These are sample datasets that are used in a variety of examples within this documentation.

Dataset

Description

abc

ABC Data

auto

Auto Data

berqsherm

Data from the Berquist Sherman paper

cc_sample

Sample Insurance Data for Cape Cod Method in Struhuss

clrd

CAS Loss Reserving Database

genins

General Insurance Data used in Clark

ia_sample

Sample data for Incremental Additive Method in Schmidt

liab

more data

m3ir5

more data

mcl

Sample insurance data for Munich Adjustment in Quarg

mortgage

more data

mw2008

more data

mw2014

more data

quarterly

Sample data to demonstrate changing Triangle grain

raa

Sample data used in Mack Chainladder

ukmotor

more data

usaa

more data

usauto

more data

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')
/home/docs/checkouts/readthedocs.org/user_builds/chainladder-python/conda/latest/lib/python3.11/site-packages/chainladder/utils/utility_functions.py:113: FutureWarning: Passing literal json to 'read_json' is deprecated and will be removed in a future version. To read from a literal string, wrap it in a 'StringIO' object.
  y = pd.read_json(j["data"], orient="split", date_unit="ns")
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.