forked from casact/chainladder-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_mack.py
26 lines (22 loc) · 780 Bytes
/
plot_mack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
========================
Mack Chainladder Example
========================
This example demonstrates how you can can use the Mack Chainladder method.
"""
import pandas as pd
import chainladder as cl
# Load the data
data = cl.load_sample('raa')
# Compute Mack Chainladder ultimates and Std Err using 'volume' average
mack = cl.MackChainladder()
dev = cl.Development(average='volume')
mack.fit(dev.fit_transform(data))
# Plotting
plot_data = mack.summary_.to_frame()
g = plot_data[['Latest', 'IBNR']].plot(
kind='bar', stacked=True, ylim=(0, None), grid=True,
yerr=pd.DataFrame({'latest': plot_data['Mack Std Err']*0,
'IBNR': plot_data['Mack Std Err']}),
title='Mack Chainladder Ultimate').set(
xlabel='Accident Year', ylabel='Loss');