-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
302 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Actual Vs Expected Analysis\n\n\nThis example demonstrates how you can slice triangle objects to perform a\ntypical 'Actual vs Expected' analysis. We will use Medical Malpractice\npayment patterns for the demo.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import chainladder as cl\nimport seaborn as sns\nsns.set_style('whitegrid')\n\n# Load the data\ntri_1997 = cl.load_dataset('clrd')\ntri_1997 = tri_1997.groupby('LOB').sum().loc['medmal']['CumPaidLoss']\n\n# Create a triangle as of the previous valuation and build IBNR model\ntri_1996 = tri_1997[tri_1997.valuation < '1997']\nmodel_1996 = cl.Chainladder().fit(cl.TailCurve().fit_transform(tri_1996))\n\n# Slice the expected losses from the 1997 calendar period of the model\nave = model_1996.full_triangle_.dev_to_val()\nave = ave[ave.development == '1997'].rename('columns', 'Expected')\n\n# Slice the actual losses from the 1997 calendar period for prior AYs\nave['Actual'] = tri_1997.latest_diagonal[tri_1997.origin < '1997']\nave['Actual - Expected'] = ave['Actual'] - ave['Expected']\n\n# Plotting\nave.to_frame().T.plot(y='Actual - Expected', kind='bar', legend=False) \\\n .set(title='Calendar Period 1997 Performance',\n xlabel='Accident Period', ylabel='Actual - Expected');" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
=========================== | ||
Actual Vs Expected Analysis | ||
=========================== | ||
This example demonstrates how you can slice triangle objects to perform a | ||
typical 'Actual vs Expected' analysis. We will use Medical Malpractice | ||
payment patterns for the demo. | ||
""" | ||
|
||
import chainladder as cl | ||
import seaborn as sns | ||
sns.set_style('whitegrid') | ||
|
||
# Load the data | ||
tri_1997 = cl.load_dataset('clrd') | ||
tri_1997 = tri_1997.groupby('LOB').sum().loc['medmal']['CumPaidLoss'] | ||
|
||
# Create a triangle as of the previous valuation and build IBNR model | ||
tri_1996 = tri_1997[tri_1997.valuation < '1997'] | ||
model_1996 = cl.Chainladder().fit(cl.TailCurve().fit_transform(tri_1996)) | ||
|
||
# Slice the expected losses from the 1997 calendar period of the model | ||
ave = model_1996.full_triangle_.dev_to_val() | ||
ave = ave[ave.development == '1997'].rename('columns', 'Expected') | ||
|
||
# Slice the actual losses from the 1997 calendar period for prior AYs | ||
ave['Actual'] = tri_1997.latest_diagonal[tri_1997.origin < '1997'] | ||
ave['Actual - Expected'] = ave['Actual'] - ave['Expected'] | ||
|
||
# Plotting | ||
ave.to_frame().T.plot(y='Actual - Expected', kind='bar', legend=False) \ | ||
.set(title='Calendar Period 1997 Performance', | ||
xlabel='Accident Period', ylabel='Actual - Expected'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
d7f8f36282dc3592d0247e73221f94ea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
.. note:: | ||
:class: sphx-glr-download-link-note | ||
|
||
Click :ref:`here <sphx_glr_download_auto_examples_plot_ave_analysis.py>` to download the full example code | ||
.. rst-class:: sphx-glr-example-title | ||
|
||
.. _sphx_glr_auto_examples_plot_ave_analysis.py: | ||
|
||
|
||
=========================== | ||
Actual Vs Expected Analysis | ||
=========================== | ||
|
||
This example demonstrates how you can slice triangle objects to perform a | ||
typical 'Actual vs Expected' analysis. We will use Medical Malpractice | ||
payment patterns for the demo. | ||
|
||
|
||
|
||
|
||
.. image:: /auto_examples/images/sphx_glr_plot_ave_analysis_001.png | ||
:class: sphx-glr-single-img | ||
|
||
|
||
|
||
|
||
|
||
.. code-block:: python | ||
import chainladder as cl | ||
import seaborn as sns | ||
sns.set_style('whitegrid') | ||
# Load the data | ||
tri_1997 = cl.load_dataset('clrd') | ||
tri_1997 = tri_1997.groupby('LOB').sum().loc['medmal']['CumPaidLoss'] | ||
# Create a triangle as of the previous valuation and build IBNR model | ||
tri_1996 = tri_1997[tri_1997.valuation < '1997'] | ||
model_1996 = cl.Chainladder().fit(cl.TailCurve().fit_transform(tri_1996)) | ||
# Slice the expected losses from the 1997 calendar period of the model | ||
ave = model_1996.full_triangle_.dev_to_val() | ||
ave = ave[ave.development == '1997'].rename('columns', 'Expected') | ||
# Slice the actual losses from the 1997 calendar period for prior AYs | ||
ave['Actual'] = tri_1997.latest_diagonal[tri_1997.origin < '1997'] | ||
ave['Actual - Expected'] = ave['Actual'] - ave['Expected'] | ||
# Plotting | ||
ave.to_frame().T.plot(y='Actual - Expected', kind='bar', legend=False) \ | ||
.set(title='Calendar Period 1997 Performance', | ||
xlabel='Accident Period', ylabel='Actual - Expected'); | ||
**Total running time of the script:** ( 0 minutes 1.788 seconds) | ||
|
||
|
||
.. _sphx_glr_download_auto_examples_plot_ave_analysis.py: | ||
|
||
|
||
.. only :: html | ||
.. container:: sphx-glr-footer | ||
:class: sphx-glr-footer-example | ||
.. container:: sphx-glr-download | ||
:download:`Download Python source code: plot_ave_analysis.py <plot_ave_analysis.py>` | ||
.. container:: sphx-glr-download | ||
:download:`Download Jupyter notebook: plot_ave_analysis.ipynb <plot_ave_analysis.ipynb>` | ||
.. only:: html | ||
|
||
.. rst-class:: sphx-glr-signature | ||
|
||
`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5a6be949f7c7265f53489c50d24e5d17 | ||
f5234948aa65a93976f2a87b9155dd61 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
docs/auto_examples/plot_triangle_from_pandas_codeobj.pickle
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.