Exposure Triangle

Exposure Triangle#

import chainladder as cl
import pandas as pd

Although triangles have both origin and development attributes, it is often convenient to create premium or exposure vectors that can work with loss triangles. The Triangle class treats the development parameter as optional. This example instantiates a ‘premium’ triangle as a single vector.

# Raw premium data in pandas
premium_df = pd.DataFrame(
    {'AccYear':[item for item in range(1977, 1988)],
     'premium': [3000000]*11})

# Create a premium 'triangle' with no development
premium = cl.Triangle(premium_df, origin='AccYear', columns='premium')
premium
/home/docs/checkouts/readthedocs.org/user_builds/chainladder-python/conda/latest/lib/python3.11/site-packages/chainladder/core/triangle.py:189: UserWarning: 
            The cumulative property of your triangle is not set. This may result in
            undesirable behavior. In a future release this will result in an error.
  warnings.warn(
1987
1977 3,000,000
1978 3,000,000
1979 3,000,000
1980 3,000,000
1981 3,000,000
1982 3,000,000
1983 3,000,000
1984 3,000,000
1985 3,000,000
1986 3,000,000
1987 3,000,000
# Create some loss triangle
loss = cl.load_sample('abc')
ultimate = cl.Chainladder().fit(loss).ultimate_

loss_ratios = (ultimate / premium).to_frame()
Hide code cell source
import matplotlib.pyplot as plt
plt.style.use('ggplot')
%config InlineBackend.figure_format = 'retina'

fig, ax = plt.subplots()
plt.stem(loss_ratios.index.astype(str), loss_ratios.iloc[:, 0])
ax.grid(axis='y')
for spine in ax.spines:
    ax.spines[spine].set_visible(False)
plt.show();
../_images/570734ece2a37d19d1d47bf508007a6d3d7f4a1733fe268940b12925808dc4ab.png