-
Notifications
You must be signed in to change notification settings - Fork 73
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
123 changed files
with
1,056 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
from chainladder.methods import * | ||
from chainladder.workflow import * | ||
|
||
__version__ = '0.2.3' | ||
__version__ = '0.2.4' |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import chainladder as cl | ||
|
||
def test_struhuss(): | ||
X = cl.load_dataset('cc_sample')['loss'] | ||
X = cl.TailConstant(tail=1/0.85).fit_transform(cl.Development().fit_transform(X)) | ||
sample_weight = cl.load_dataset('cc_sample')['exposure'].latest_diagonal | ||
ibnr = int(cl.CapeCod(trend=0.07, decay=0.75).fit(X, sample_weight=sample_weight).ibnr_.sum()[0]) | ||
assert ibnr == 17052 |
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,16 @@ | ||
,origin,development,loss,exposure | ||
0,1993,1993,1058.823529,7000 | ||
1,1994,1994,1333.333333,8000 | ||
2,1995,1995,2000.0,9000 | ||
3,1996,1996,2000.0,10000 | ||
4,1997,1997,2800.0,11000 | ||
5,1993,1994,1905.8823530000002,7000 | ||
6,1994,1995,2400.0,8000 | ||
7,1995,1996,3600.0,9000 | ||
8,1996,1997,3600.0,10000 | ||
9,1993,1995,2541.176471,7000 | ||
10,1994,1996,3200.0,8000 | ||
11,1995,1997,4800.0,9000 | ||
12,1993,1996,3176.4705879999997,7000 | ||
13,1994,1997,4000.0,8000 | ||
14,1993,1997,3600.0,7000 |
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.
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.
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====================================================================\nBenktander: Relationship between Chainladder and BornhuetterFerguson\n====================================================================\n\nThis example demonstrates the relationship between the Chainladder and\nBornhuetterFerguson methods by way fo the Benktander model. Each is a\nspecial case of the Benktander model where `n_iters = 1` for BornhuetterFerguson\nand as `n_iters` approaches infinity yields the chainladder. As `n_iters`\nincreases the apriori selection becomes less relevant regardless of initial\nchoice.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import chainladder as cl\n\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nsns.set_style('whitegrid')\n\n# Load Data\nclrd = cl.load_dataset('clrd')\nmedmal_paid = clrd.groupby('LOB').sum().loc['medmal']['CumPaidLoss']\nmedmal_prem = clrd.groupby('LOB').sum().loc['medmal']['EarnedPremDIR'].latest_diagonal\nmedmal_prem.rename(development='premium')\n\n# Generate LDFs and Tail Factor\nmedmal_paid = cl.Development().fit_transform(medmal_paid)\nmedmal_paid = cl.TailCurve().fit_transform(medmal_paid)\n\n# Benktander Model\nbenk = cl.Benktander()\n\n# Prep Benktander Grid Search with various assumptions, and a scoring function\nparam_grid = dict(n_iters=list(range(1,100,2)),\n apriori=[0.50, 0.75, 1.00])\nscoring = {'IBNR':lambda x: x.ibnr_.sum()[0]}\ngrid = cl.GridSearch(benk, param_grid, scoring=scoring)\n# Perform Grid Search\ngrid.fit(medmal_paid, sample_weight=medmal_prem)\n\n# Plot data\ngrid.results_.pivot(index='n_iters', columns='apriori', values='IBNR').plot()\nplt.title('Benktander convergence to Chainladder')\ng = plt.ylabel('IBNR')" | ||
] | ||
} | ||
], | ||
"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,43 @@ | ||
""" | ||
==================================================================== | ||
Benktander: Relationship between Chainladder and BornhuetterFerguson | ||
==================================================================== | ||
This example demonstrates the relationship between the Chainladder and | ||
BornhuetterFerguson methods by way fo the Benktander model. Each is a | ||
special case of the Benktander model where `n_iters = 1` for BornhuetterFerguson | ||
and as `n_iters` approaches infinity yields the chainladder. As `n_iters` | ||
increases the apriori selection becomes less relevant regardless of initial | ||
choice. | ||
""" | ||
import chainladder as cl | ||
|
||
import seaborn as sns | ||
import matplotlib.pyplot as plt | ||
sns.set_style('whitegrid') | ||
|
||
# Load Data | ||
clrd = cl.load_dataset('clrd') | ||
medmal_paid = clrd.groupby('LOB').sum().loc['medmal']['CumPaidLoss'] | ||
medmal_prem = clrd.groupby('LOB').sum().loc['medmal']['EarnedPremDIR'].latest_diagonal | ||
medmal_prem.rename(development='premium') | ||
|
||
# Generate LDFs and Tail Factor | ||
medmal_paid = cl.Development().fit_transform(medmal_paid) | ||
medmal_paid = cl.TailCurve().fit_transform(medmal_paid) | ||
|
||
# Benktander Model | ||
benk = cl.Benktander() | ||
|
||
# Prep Benktander Grid Search with various assumptions, and a scoring function | ||
param_grid = dict(n_iters=list(range(1,100,2)), | ||
apriori=[0.50, 0.75, 1.00]) | ||
scoring = {'IBNR':lambda x: x.ibnr_.sum()[0]} | ||
grid = cl.GridSearch(benk, param_grid, scoring=scoring) | ||
# Perform Grid Search | ||
grid.fit(medmal_paid, sample_weight=medmal_prem) | ||
|
||
# Plot data | ||
grid.results_.pivot(index='n_iters', columns='apriori', values='IBNR').plot() | ||
plt.title('Benktander convergence to Chainladder') | ||
g = plt.ylabel('IBNR') |
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 @@ | ||
7d348baf6a5767e0aa7b52f411601199 |
Oops, something went wrong.