├── .coveragerc ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── pytest.yml │ ├── pytest_upstream_nightly.yml │ └── pythonpublish.yml ├── .gitignore ├── LICENSE ├── MANIFEST.in ├── README.rst ├── benchmarks ├── __init__.py ├── asv.conf.json └── benchmarks.py ├── chainladder ├── __init__.py ├── adjustments │ ├── __init__.py │ ├── berqsherm.py │ ├── bootstrap.py │ ├── parallelogram.py │ ├── tests │ │ ├── __init__.py │ │ ├── test_berqsherm.py │ │ ├── test_bootstrap.py │ │ ├── test_parallelogram.py │ │ └── test_trend.py │ └── trend.py ├── core │ ├── README.md │ ├── __init__.py │ ├── base.py │ ├── common.py │ ├── correlation.py │ ├── display.py │ ├── dunders.py │ ├── io.py │ ├── pandas.py │ ├── slice.py │ ├── tests │ │ ├── __init__.py │ │ ├── rtest_correlation.py │ │ ├── test_arithmetic.py │ │ ├── test_correlation.py │ │ ├── test_display.py │ │ ├── test_grain.py │ │ ├── test_slicing.py │ │ └── test_triangle.py │ └── triangle.py ├── development │ ├── __init__.py │ ├── barnzehn.py │ ├── base.py │ ├── clark.py │ ├── constant.py │ ├── development.py │ ├── glm.py │ ├── incremental.py │ ├── learning.py │ ├── munich.py │ ├── outstanding.py │ └── tests │ │ ├── rtest_clark.py │ │ ├── rtest_development.py │ │ ├── rtest_munich.py │ │ ├── test_constant.py │ │ ├── test_development.py │ │ ├── test_glm.py │ │ ├── test_incremental.py │ │ ├── test_munich.py │ │ └── test_outstanding.py ├── methods │ ├── __init__.py │ ├── base.py │ ├── benktander.py │ ├── bornferg.py │ ├── capecod.py │ ├── chainladder.py │ ├── expectedloss.py │ ├── mack.py │ └── tests │ │ ├── __init__.py │ │ ├── rtest_mack.py │ │ ├── test_benktander.py │ │ ├── test_capecod.py │ │ ├── test_mack.py │ │ └── test_predict.py ├── tails │ ├── __init__.py │ ├── base.py │ ├── bondy.py │ ├── clark.py │ ├── constant.py │ ├── curve.py │ └── tests │ │ ├── __init__.py │ │ ├── rtest_exponential.py │ │ ├── test_bondy.py │ │ ├── test_constant.py │ │ └── test_exponential.py ├── utils │ ├── __init__.py │ ├── cupy.py │ ├── dask.py │ ├── data │ │ ├── abc.csv │ │ ├── auto.csv │ │ ├── berqsherm.csv │ │ ├── cc_sample.csv │ │ ├── clrd.csv │ │ ├── friedland_auto_bi_insurer.csv │ │ ├── friedland_auto_freq_sev.csv │ │ ├── friedland_auto_salsub.csv │ │ ├── friedland_autoprop.csv │ │ ├── friedland_berq_sher_auto.csv │ │ ├── friedland_gl_insurer.csv │ │ ├── friedland_med_mal.csv │ │ ├── friedland_qs.csv │ │ ├── friedland_us_auto_chg_prod_mix.csv │ │ ├── friedland_us_auto_incr_claim.csv │ │ ├── friedland_us_auto_steady_state.csv │ │ ├── friedland_us_industry_auto.csv │ │ ├── friedland_us_industry_auto_case.csv │ │ ├── friedland_uspp_auto_increasing_case.csv │ │ ├── friedland_uspp_auto_increasing_claim.csv │ │ ├── friedland_uspp_auto_steady_state.csv │ │ ├── friedland_uspp_increasing_claim_case.csv │ │ ├── friedland_wc_self_insurer.csv │ │ ├── friedland_xol.csv │ │ ├── friedland_xyz_auto_bi.csv │ │ ├── friedland_xyz_case.csv │ │ ├── friedland_xyz_disp.csv │ │ ├── friedland_xyz_freq_sev.csv │ │ ├── genins.csv │ │ ├── ia_sample.csv │ │ ├── liab.csv │ │ ├── m3ir5.csv │ │ ├── mack_1997.csv │ │ ├── mcl.csv │ │ ├── mortgage.csv │ │ ├── mw2008.csv │ │ ├── mw2014.csv │ │ ├── prism.csv │ │ ├── quarterly.csv │ │ ├── raa.csv │ │ ├── tail_sample.csv │ │ ├── ukmotor.csv │ │ ├── usaa.csv │ │ ├── usauto.csv │ │ └── xyz.csv │ ├── sparse.py │ ├── tests │ │ ├── __init__.py │ │ └── test_utilities.py │ ├── utility_functions.py │ └── weighted_regression.py └── workflow │ ├── __init__.py │ ├── gridsearch.py │ ├── tests │ ├── __init__.py │ ├── test_predict.py │ ├── test_voting.py │ └── test_workflow.py │ └── voting.py ├── ci ├── environment-latest.yaml └── environment-test.yaml ├── conftest.py ├── docs ├── Makefile ├── _config.yml ├── _toc.yml ├── conf.py ├── gallery │ ├── index.md │ ├── plot_advanced_triangle.ipynb │ ├── plot_ave_analysis.ipynb │ ├── plot_benktander.ipynb │ ├── plot_berqsherm_case.ipynb │ ├── plot_bf_apriori_from_cl.ipynb │ ├── plot_bondy_sensitivity.ipynb │ ├── plot_bootstrap.ipynb │ ├── plot_bootstrap_comparison.ipynb │ ├── plot_callable_dev_constant.ipynb │ ├── plot_capecod.ipynb │ ├── plot_capecod_onlevel.ipynb │ ├── plot_clarkldf.ipynb │ ├── plot_clarkldf_resid.ipynb │ ├── plot_development_periods.ipynb │ ├── plot_elrf_resid.ipynb │ ├── plot_exponential_smoothing.ipynb │ ├── plot_exposure_triangle.ipynb │ ├── plot_extrap_period.ipynb │ ├── plot_glm_ldf.ipynb │ ├── plot_ibnr_runoff.ipynb │ ├── plot_industry_to_company.ipynb │ ├── plot_mack.ipynb │ ├── plot_munich.ipynb │ ├── plot_munich_resid.ipynb │ ├── plot_ptf_resid.ipynb │ ├── plot_stochastic_bornferg.ipynb │ ├── plot_tailcurve_compare.ipynb │ ├── plot_triangle_from_pandas.ipynb │ ├── plot_triangle_slicing.ipynb │ ├── plot_value_at_risk.ipynb │ └── plot_voting_chainladder.ipynb ├── getting_started │ ├── index.md │ ├── install.md │ ├── online_sandbox │ │ ├── sandbox_intro.md │ │ ├── sandbox_workbook_blank.ipynb │ │ └── sandbox_workbook_filled.ipynb │ └── tutorials │ │ ├── data-tutorial.ipynb │ │ ├── deterministic-tutorial.ipynb │ │ ├── development-tutorial.ipynb │ │ ├── index.md │ │ ├── stochastic-tutorial.ipynb │ │ ├── tail-tutorial.ipynb │ │ └── triangle-tutorial.ipynb ├── images │ ├── logo.png │ ├── onlevel.PNG │ ├── plot_advanced_triangle.png │ ├── plot_ave_analysis.png │ ├── plot_benktander.png │ ├── plot_berqsherm_case.png │ ├── plot_bf_apriori_from_cl.png │ ├── plot_bondy_sensitivity.png │ ├── plot_bootstrap.png │ ├── plot_bootstrap_comparison.png │ ├── plot_bootstrap_comparison.svg │ ├── plot_callable_dev_constant.png │ ├── plot_capecod.png │ ├── plot_capecod_onlevel.png │ ├── plot_clarkldf.png │ ├── plot_clarkldf_resid.png │ ├── plot_development_periods.png │ ├── plot_elrf_resid.png │ ├── plot_exponential_smoothing.png │ ├── plot_exposure_triangle.png │ ├── plot_extrap_period.png │ ├── plot_glm_ldf.png │ ├── plot_ibnr_runoff.png │ ├── plot_mack.png │ ├── plot_munich.png │ ├── plot_munich_resid.png │ ├── plot_ptf_resid.png │ ├── plot_stochastic_bornferg.png │ ├── plot_tailcurve_compare.png │ ├── plot_triangle_from_pandas.png │ ├── plot_triangle_slicing.png │ ├── plot_value_at_risk.png │ ├── plot_voting_chainladder.png │ ├── prob_trend_family.PNG │ ├── triangle_bad_good.PNG │ └── triangle_graphic.PNG ├── intro.md ├── library │ ├── about.md │ ├── api.md │ ├── contributing.md │ ├── generated │ │ ├── chainladder.BarnettZehnwirth.rst │ │ ├── chainladder.Benktander.rst │ │ ├── chainladder.BerquistSherman.rst │ │ ├── chainladder.BootstrapODPSample.rst │ │ ├── chainladder.BornhuetterFerguson.rst │ │ ├── chainladder.CapeCod.rst │ │ ├── chainladder.CaseOutstanding.rst │ │ ├── chainladder.Chainladder.rst │ │ ├── chainladder.ClarkLDF.rst │ │ ├── chainladder.Development.rst │ │ ├── chainladder.DevelopmentConstant.rst │ │ ├── chainladder.DevelopmentCorrelation.rst │ │ ├── chainladder.DevelopmentML.rst │ │ ├── chainladder.GridSearch.rst │ │ ├── chainladder.IncrementalAdditive.rst │ │ ├── chainladder.MackChainladder.rst │ │ ├── chainladder.MunichAdjustment.rst │ │ ├── chainladder.ParallelogramOLF.rst │ │ ├── chainladder.PatsyFormula.rst │ │ ├── chainladder.Pipeline.rst │ │ ├── chainladder.TailBondy.rst │ │ ├── chainladder.TailClark.rst │ │ ├── chainladder.TailConstant.rst │ │ ├── chainladder.TailCurve.rst │ │ ├── chainladder.Trend.rst │ │ ├── chainladder.Triangle.rst │ │ ├── chainladder.TweedieGLM.rst │ │ ├── chainladder.ValuationCorrelation.rst │ │ ├── chainladder.VotingChainladder.rst │ │ ├── chainladder.concat.rst │ │ ├── chainladder.load_sample.rst │ │ ├── chainladder.maximum.rst │ │ ├── chainladder.minimum.rst │ │ ├── chainladder.read_json.rst │ │ └── chainladder.read_pickle.rst │ ├── glossary.md │ ├── presentation_assets │ │ ├── concurrent_session.md │ │ ├── demo-blank-concurrent.ipynb │ │ ├── roundtable_session.md │ │ ├── star-history-20221003.csv │ │ ├── star-history-20230403.csv │ │ ├── star-history-20231006.csv │ │ ├── star_history.ipynb │ │ ├── technology_survey_responses_2022.csv │ │ └── webinar_demo.md │ ├── questions_issues.md │ ├── references.bib │ ├── references.md │ ├── releases.md │ ├── roadmap.md │ ├── sample_data.md │ ├── source_code.md │ └── usage.md ├── make.bat └── user_guide │ ├── adjustments.ipynb │ ├── development.ipynb │ ├── index.md │ ├── methods.ipynb │ ├── tails.ipynb │ ├── triangle.ipynb │ ├── utilities.ipynb │ └── workflow.ipynb ├── environment-dev.yaml ├── environment-docs.yaml ├── readthedocs.yaml ├── requirements.txt ├── setup.cfg └── setup.py /.coveragerc: -------------------------------------------------------------------------------- 1 | # .coveragerc to control coverage.py 2 | [run] 3 | branch = True 4 | omit = *tests* 5 | 6 | [report] 7 | show_missing = True 8 | 9 | # Regexes for lines to exclude from consideration 10 | exclude_lines = 11 | # Have to re-enable the standard pragma 12 | pragma: no cover 13 | 14 | # Don't complain about missing debug-only code: 15 | def __repr__ 16 | if self\.debug 17 | 18 | # Don't complain if tests don't hit defensive assertion code: 19 | raise AssertionError 20 | raise NotImplementedError 21 | 22 | # Don't complain if non-runnable code isn't run: 23 | if 0: 24 | if __name__ == .__main__.: 25 | 26 | # Don't count test code 27 | ^def test_ 28 | 29 | ignore_errors = False 30 | 31 | [html] 32 | directory = coverage_html_report 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: Bug 6 | assignees: jbogaardt 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. Code should be self-contained and runnable against publicly available data. For example: 15 | ```python 16 | import chainladder as cl 17 | triangle = cl.load_sample('raa') 18 | ``` 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. If it can be expressed in code, then that is better. The complete code can serve as a unit test. 22 | ```python 23 | assert triangle.shape == (1, 1, 10, 10) 24 | ``` 25 | 26 | **Desktop (please complete the following information):** 27 | - Numpy Version [e.g. 1.22.0] 28 | - Pandas Version [e.g. 1.4.1] 29 | - Chainladder Version [e.g. 0.8.13] 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[ENH] Description" 5 | labels: Enhancement 6 | assignees: jbogaardt 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Is your feature request at odds with the scope of the package?** 14 | The ethos governing `chainladder-python` is that it: 15 | 1. Is an engine for triangle manipulation and reserve setting. It is not a reserving system, but can be a major component in a reserving system, such as [FASLR](https://faslr.com/). 16 | 2. Conforms to `pandas` and `sklearn` API in a strict sense. Deviations from these APIs is discouraged. 17 | 18 | **Describe the solution you'd like** 19 | A clear and concise description of what you want to happen. 20 | 21 | **Describe alternatives you've considered** 22 | A clear and concise description of any alternative solutions or features you've considered. 23 | 24 | **Additional context** 25 | Add any other context or screenshots about the feature request here. 26 | -------------------------------------------------------------------------------- /.github/workflows/pytest.yml: -------------------------------------------------------------------------------- 1 | name: Unit Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | pull_request: 8 | branches: 9 | - '*' 10 | 11 | jobs: 12 | linux: 13 | name: (${{ matrix.python-version }}, ${{ matrix.os }}) 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | os: ['ubuntu-latest'] #, 'macos-latest', 'windows-latest'] 19 | python-version: ['3.9'] 20 | steps: 21 | - uses: actions/checkout@v1 22 | - uses: conda-incubator/setup-miniconda@v2 23 | with: 24 | auto-update-conda: true 25 | python-version: ${{ matrix.python-version }} 26 | - name: Install repo and dependencies 27 | shell: bash -l {0} 28 | run: | 29 | conda install mamba -y -c conda-forge -n base 30 | mamba env create --file ./ci/environment-test.yaml; 31 | conda activate cl_test; 32 | python setup.py develop 33 | pytest --cov=chainladder --cov-report=xml 34 | - name: Upload coverage to Codecov 35 | uses: codecov/codecov-action@v1 36 | with: 37 | token: ${{ secrets.CODECOV_TOKEN }} 38 | file: ./coverage.xml 39 | flags: unittests 40 | name: codecov-umbrella 41 | fail_ci_if_error: false 42 | -------------------------------------------------------------------------------- /.github/workflows/pytest_upstream_nightly.yml: -------------------------------------------------------------------------------- 1 | name: CI Upstream 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | branches: 8 | - master 9 | schedule: 10 | - cron: "0 0 * * *" # Daily “At 00:00” UTC 11 | workflow_dispatch: # allows you to trigger the workflow run manually 12 | 13 | jobs: 14 | linux: 15 | name: (${{ matrix.python-version }}, ${{ matrix.os }}) 16 | runs-on: ${{ matrix.os }} 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | os: ['ubuntu-latest'] #, 'macos-latest', 'windows-latest'] 21 | python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] 22 | steps: 23 | - uses: actions/checkout@v1 24 | - uses: conda-incubator/setup-miniconda@v2 25 | with: 26 | auto-update-conda: true 27 | python-version: ${{ matrix.python-version }} 28 | - name: Install repo and dependencies 29 | shell: bash -l {0} 30 | run: | 31 | conda install mamba -y -c conda-forge -n base 32 | mamba env create --file ./ci/environment-latest.yaml; 33 | conda activate cl_latest; 34 | python setup.py develop 35 | pytest chainladder -m "not r" 36 | -------------------------------------------------------------------------------- /.github/workflows/pythonpublish.yml: -------------------------------------------------------------------------------- 1 | name: Upload Python Package 2 | 3 | on: 4 | release: 5 | types: [created] 6 | workflow_dispatch: 7 | 8 | permissions: 9 | id-token: write 10 | contents: read 11 | 12 | jobs: 13 | deploy: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v1 17 | - name: Set up Python 18 | uses: actions/setup-python@v1 19 | with: 20 | python-version: '3.x' 21 | - name: Install dependencies 22 | run: | 23 | python -m pip install --upgrade pip 24 | pip install setuptools wheel twine 25 | - name: Build and publish 26 | env: 27 | TWINE_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} 28 | run: | 29 | python setup.py sdist bdist_wheel 30 | twine upload dist/* 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | .pytest_cache/ 3 | __pycache__/ 4 | *.py[cod] 5 | *$py.class 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | env/ 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | 29 | # Excel Files 30 | *.xlsx 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .coverage 46 | .coverage.* 47 | .cache 48 | nosetests.xml 49 | coverage.xml 50 | *.cover 51 | .hypothesis/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | docs/auto_examples/ 71 | docs/modules/generated/ 72 | 73 | # PyBuilder 74 | target/ 75 | 76 | # Jupyter Notebook 77 | .ipynb_checkpoints 78 | 79 | # pyenv 80 | .python-version 81 | 82 | # celery beat schedule file 83 | celerybeat-schedule 84 | 85 | # SageMath parsed files 86 | *.sage.py 87 | 88 | # dotenv 89 | .env 90 | 91 | # virtualenv 92 | .venv 93 | venv/ 94 | ENV/ 95 | 96 | # Spyder project settings 97 | .spyderproject 98 | .spyproject 99 | 100 | # Rope project settings 101 | .ropeproject 102 | 103 | # mkdocs documentation 104 | /site 105 | 106 | # mypy 107 | .mypy_cache/ 108 | 109 | # references 110 | references/ 111 | 112 | settings.json 113 | 114 | *.pkl 115 | 116 | # macOS related files 117 | *.DS_Store 118 | *Icon? 119 | *.r 120 | 121 | # asv environments 122 | .asv 123 | 124 | coverage_html_report 125 | 126 | # Random python test workbooks 127 | Untitled.ipynb -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include requirements.txt 3 | include README.rst 4 | 5 | include chainladder/utils/data/abc.csv 6 | include chainladder/utils/data/auto.csv 7 | include chainladder/utils/data/clrd.csv 8 | include chainladder/utils/data/genins.csv 9 | include chainladder/utils/data/liab.csv 10 | include chainladder/utils/data/m3ir5.csv 11 | include chainladder/utils/data/mcl.csv 12 | include chainladder/utils/data/mortgage.csv 13 | include chainladder/utils/data/mw2008.csv 14 | include chainladder/utils/data/mw2014.csv 15 | include chainladder/utils/data/quarterly.csv 16 | include chainladder/utils/data/raa.csv 17 | include chainladder/utils/data/ukmotor.csv 18 | include chainladder/utils/data/usaa.csv 19 | include chainladder/utils/data/usauto.csv 20 | include chainladder/utils/data/cc_sample.csv 21 | include chainladder/utils/data/ia_sample.csv 22 | include chainladder/utils/data/prism.csv 23 | include chainladder/utils/data/tail_sample.csv 24 | include chainladder/utils/data/berqsherm.csv 25 | include chainladder/utils/data/xyz.csv -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. -*- mode: rst -*- 2 | 3 | .. |PyPI version| image:: https://badge.fury.io/py/chainladder.svg 4 | :target: https://badge.fury.io/py/chainladder 5 | 6 | .. |Conda Version| image:: https://img.shields.io/conda/vn/conda-forge/chainladder.svg 7 | :target: https://anaconda.org/conda-forge/chainladder 8 | 9 | .. |Build Status| image:: https://github.com/casact/chainladder-python/workflows/Unit%20Tests/badge.svg 10 | 11 | .. |Documentation Status| image:: https://readthedocs.org/projects/chainladder-python/badge/?version=latest 12 | :target: https://chainladder-python.readthedocs.io/en/latest/?badge=latest 13 | 14 | .. |codecov io| image:: https://codecov.io/gh/casact/chainladder-python/branch/master/graphs/badge.svg 15 | :target: https://codecov.io/github/casact/chainladder-python?branch=latest 16 | 17 | chainladder (python) 18 | ==================== 19 | 20 | |PyPI version| |Conda Version| |Build Status| |codecov io| |Documentation Status| 21 | 22 | chainladder: Property and Casualty Loss Reserving in Python 23 | ------------------------------------------------------------ 24 | 25 | Welcome! The chainladder package was built to be able to handle all of your actuarial needs in python. It consists of popular actuarial tools, such as triangle data manipulation, link ratios calculation, and IBNR estimates with both deterministic and stochastic models. We build this package so you no longer have to rely on outdated softwares and tools when performing actuarial pricing or reserving indications. 26 | 27 | This package strives to be minimalistic in needing its own API. The syntax mimics popular packages `pandas`_ for data manipulation and `scikit-learn`_ for model 28 | construction. An actuary that is already familiar with these tools will be able to pick up this package with ease. You will be able to save your mental energy for actual actuarial work. 29 | 30 | Chainladder is built by a group of volunteers, and we need YOUR help! 31 | 32 | This package is written in Python, if you are looking for a similar package written in R, please visit `chainladder`_. 33 | 34 | .. _pandas: https://pandas.pydata.org/ 35 | .. _scikit-learn: https://scikit-learn.org/stable/ 36 | .. _chainladder: https://github.com/mages/ChainLadder 37 | 38 | 39 | Dedicated Documentation Site 40 | ---------------------------- 41 | 42 | We have a dedicated documentation website, where you can find installation instructions, tutorials, example galleries, sample datasets, API references, change log history, and more. 43 | 44 | Visit `Chainladder-Python on Read the Docs`_. 45 | 46 | .. _Chainladder-Python on Read the Docs: https://chainladder-python.readthedocs.io/ 47 | 48 | Licenses 49 | ------------------- 50 | This package is released under `Mozilla Public License 2.0`_. 51 | 52 | .. _Mozilla Public License 2.0: https://github.com/casact/chainladder-python/blob/master/LICENSE 53 | -------------------------------------------------------------------------------- /benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /benchmarks/benchmarks.py: -------------------------------------------------------------------------------- 1 | # Write the benchmarking functions here. 2 | # See "Writing benchmarks" in the asv docs for more information. 3 | import chainladder as cl 4 | 5 | class TimeSuite: 6 | def setup(self): 7 | self.prism = cl.load_sample('prism') 8 | 9 | def time_incr_to_cum(self): 10 | self.prism.incr_to_cum() 11 | 12 | def time_groupby(self): 13 | self.prism.groupby(['Line']).sum() 14 | 15 | def time_index_broadcasting(self): 16 | self.prism / self.prism.groupby(['Line']).sum() 17 | 18 | def time_grain(self): 19 | self.prism.grain('OYDY') 20 | 21 | def time_dev_to_val(self): 22 | self.prism.dev_to_val() 23 | 24 | def time_val_to_dev(self): 25 | self.prism.dev_to_val().val_to_dev() 26 | 27 | def time_fit_chainladder(self): 28 | cl.Chainladder().fit( 29 | cl.Development(groupby=lambda x : 1).fit_transform(self.prism['Paid']) 30 | ).ibnr_ 31 | 32 | class MemSuite: 33 | def setup(self): 34 | self.prism = cl.load_sample('prism') 35 | 36 | def peakmem_incr_to_cum(self): 37 | self.prism.incr_to_cum() 38 | 39 | def peakmem_groupby(self): 40 | self.prism.groupby(['Line']).sum() 41 | 42 | def peakmem_index_broadcasting(self): 43 | self.prism / self.prism.groupby(['Line']).sum() 44 | 45 | def peakmem_grain(self): 46 | self.prism.grain('OYDY') 47 | 48 | def peakmem_dev_to_val(self): 49 | self.prism.dev_to_val() 50 | 51 | def peakmem_val_to_dev(self): 52 | self.prism.dev_to_val().val_to_dev() 53 | 54 | def peakmem_fit_chainladder(self): 55 | cl.Chainladder().fit( 56 | cl.Development(groupby=lambda x : 1).fit_transform(self.prism['Paid']) 57 | ).ibnr_ 58 | -------------------------------------------------------------------------------- /chainladder/__init__.py: -------------------------------------------------------------------------------- 1 | from sklearn.utils import deprecated 2 | 3 | class Options: 4 | ARRAY_BACKEND = "numpy" 5 | AUTO_SPARSE = True 6 | ARRAY_PRIORITY = ["dask", "sparse", "cupy", "numpy"] 7 | ULT_VAL = "2261-12-31 23:59:59.999999999" 8 | 9 | @classmethod 10 | def get_option(cls, option=None): 11 | return getattr(cls, option) 12 | 13 | @classmethod 14 | def set_option(cls, option, value): 15 | setattr(cls, option, value) 16 | 17 | def reset_option(self): 18 | self.set_option('ARRAY_BACKEND', "numpy") 19 | self.set_option('AUTO_SPARSE', True) 20 | self.set_option('ARRAY_PRIORITY', ["dask", "sparse", "cupy", "numpy"]) 21 | self.set_option('ULT_VAL', "2261-12-31 23:59:59.999999999") 22 | 23 | def describe_option(self): 24 | pass 25 | 26 | options = Options() 27 | 28 | @deprecated("In an upcoming version of the package, this function will be deprecated. Use `chainladder.options.set_option('ARRAY_BACKEND', value)` to avoid breakage.") 29 | def array_backend(array_backend="numpy"): 30 | options.set_option('ARRAY_BACKEND', array_backend) 31 | 32 | @deprecated("In an upcoming version of the package, this function will be deprecated. Use `chainladder.options.set_option('AUTO_SPARSE', value)` to avoid breakage.") 33 | def auto_sparse(auto_sparse=True): 34 | options.set_option('AUTO_SPARSE', auto_sparse) 35 | 36 | 37 | from chainladder.utils import * # noqa (API Import) 38 | from chainladder.core import * # noqa (API Import) 39 | from chainladder.development import * # noqa (API Import) 40 | from chainladder.adjustments import * # noqa (API Import) 41 | from chainladder.tails import * # noqa (API Import) 42 | from chainladder.methods import * # noqa (API Import) 43 | from chainladder.workflow import * # noqa (API Import) 44 | 45 | __version__ = "0.8.24" 46 | -------------------------------------------------------------------------------- /chainladder/adjustments/__init__.py: -------------------------------------------------------------------------------- 1 | from chainladder.adjustments.bootstrap import BootstrapODPSample # noqa (API import) 2 | from chainladder.adjustments.berqsherm import BerquistSherman # noqa (API import) 3 | from chainladder.adjustments.parallelogram import ParallelogramOLF # noqa (API import) 4 | from chainladder.adjustments.trend import Trend # noqa (API import) 5 | from chainladder.adjustments.trend import TrendConstant # noqa (API import) 6 | -------------------------------------------------------------------------------- /chainladder/adjustments/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/chainladder/adjustments/tests/__init__.py -------------------------------------------------------------------------------- /chainladder/adjustments/tests/test_berqsherm.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import numpy as np 3 | 4 | 5 | def test_preserve_diagonal(): 6 | triangle = cl.load_sample("berqsherm").loc["Auto"] 7 | xp = triangle.get_array_module() 8 | berq = cl.BerquistSherman( 9 | paid_amount="Paid", 10 | incurred_amount="Incurred", 11 | reported_count="Reported", 12 | closed_count="Closed", 13 | ) 14 | berq_triangle = berq.fit_transform(triangle) 15 | assert ( 16 | xp.nansum((berq_triangle.latest_diagonal - triangle.latest_diagonal).values) 17 | == 0 18 | ) 19 | assert berq_triangle != triangle 20 | 21 | def test_adjusted_values(): 22 | triangle = cl.load_sample("berqsherm").loc["MedMal"] 23 | xp = triangle.get_array_module() 24 | berq = cl.BerquistSherman( 25 | paid_amount="Paid", 26 | incurred_amount="Incurred", 27 | reported_count="Reported", 28 | closed_count="Closed", 29 | trend=0.15, 30 | ) 31 | berq_triangle = berq.fit_transform(triangle) 32 | 33 | assert np.allclose( 34 | triangle["Reported"].values, berq_triangle["Reported"].values, equal_nan=True 35 | ) 36 | 37 | # Ensure that the incurred, paid, and closed count columns are as expected 38 | berq_triangle.values[np.isnan(berq_triangle.values)] = 0 39 | assert np.isclose( 40 | berq_triangle["Incurred"].values.sum(), 1126985253.661, atol=1e-2 41 | ) 42 | assert np.isclose(berq_triangle["Paid"].values.sum(), 182046766.054, atol=1e-2) 43 | assert np.isclose(berq_triangle["Closed"].values.sum(), 8798.982, atol=1e-2) -------------------------------------------------------------------------------- /chainladder/adjustments/tests/test_bootstrap.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import numpy as np 3 | 4 | 5 | def test_bs_sample(raa): 6 | tri = raa 7 | a = ( 8 | cl.Development() 9 | .fit(cl.BootstrapODPSample(n_sims=40000).fit_transform(tri).mean()) 10 | .ldf_ 11 | ) 12 | b = cl.Development().fit_transform(tri).ldf_ 13 | assert tri.get_array_module().all(abs(((a - b) / b).values) < 0.005) 14 | 15 | def test_bs_multiple_cols(): 16 | assert cl.BootstrapODPSample().fit_transform( 17 | cl.load_sample('berqsherm').iloc[0]).shape == (1000, 4, 8, 8) 18 | -------------------------------------------------------------------------------- /chainladder/adjustments/tests/test_parallelogram.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import pandas as pd 3 | 4 | 5 | def test_parallelogram(clrd): 6 | lob = ["wkcomp"] * 3 + ["comauto"] * 3 + ["wkcomp"] * 2 7 | values = [0.05, 0.02, -0.1, 0.05, 0.05, 0.05, 0.2, 1 / 1.1 - 1] 8 | date = [ 9 | "1/1/1989", 10 | "2/14/1990", 11 | "10/1/1992", 12 | "7/1/1988", 13 | "1/1/1990", 14 | "10/1/1993", 15 | "1/1/1996", 16 | "10/1/1992", 17 | ] 18 | rates = pd.DataFrame({"LOB": lob, "effdate": date, "change": values}) 19 | 20 | olf = cl.ParallelogramOLF( 21 | rate_history=rates, change_col="change", date_col="effdate" 22 | ) 23 | 24 | X = clrd["EarnedPremNet"].latest_diagonal 25 | X = X[X["LOB"].isin(["wkcomp", "comauto"])] 26 | X = olf.fit_transform(X) 27 | assert X.get_array_module().all( 28 | X.olf_.loc["comauto", "EarnedPremNet", "1994"].values 29 | - (9 / 12 * 9 / 12 / 2 * 0.05 + 1) 30 | < 0.005 31 | ) 32 | assert X.get_array_module().all( 33 | X.olf_.loc["wkcomp", "EarnedPremNet", "1996"].values - 1.1 < 0.005 34 | ) 35 | -------------------------------------------------------------------------------- /chainladder/adjustments/tests/test_trend.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import numpy as np 3 | 4 | 5 | def test_trend1(clrd): 6 | tri = clrd[["CumPaidLoss", "EarnedPremDIR"]].sum() 7 | lhs = ( 8 | cl.CapeCod(0.05) 9 | .fit(tri["CumPaidLoss"], sample_weight=tri["EarnedPremDIR"].latest_diagonal) 10 | .ibnr_ 11 | ) 12 | rhs = ( 13 | cl.CapeCod() 14 | .fit( 15 | cl.Trend(0.05).fit_transform(tri["CumPaidLoss"]), 16 | sample_weight=tri["EarnedPremDIR"].latest_diagonal, 17 | ) 18 | .ibnr_ 19 | ) 20 | assert np.round(lhs, 0) == np.round(rhs, 0) 21 | 22 | 23 | def test_trend2(raa): 24 | tri = raa 25 | assert ( 26 | abs( 27 | cl.Trend( 28 | trends=[0.05, 0.05], 29 | dates=[(None, "1985"), ("1985", None)], 30 | axis="origin", 31 | ) 32 | .fit(tri) 33 | .trend_ 34 | * tri 35 | - tri.trend(0.05, axis="origin") 36 | ) 37 | .sum() 38 | .sum() 39 | < 1e-6 40 | ) 41 | -------------------------------------------------------------------------------- /chainladder/core/README.md: -------------------------------------------------------------------------------- 1 | ### Core 2 | 3 | 4 | '/chainladder/core' houses the core data structure of the library, the `Triangle`. 5 | 6 | #### File descriptions 7 | **base.py** - Functionality for initializing a triangle. 8 |
**slice.py** - Functionality for `loc` and `iloc` slicing, boolean-indexing, 9 |
**pandas.py** - Pandas style methods extended to Triangle class such as `groupby` functionality 10 |
**io.py** - pickle and json serialization 11 |
**triangle.py** - chainladder specific methods not covered by pandas 12 |
**dunders.py** - Operator overloading (add, subtract, multiply, divide) 13 |
**display.py** - Jupyter and REPL outputs of Triangle. 14 |
**common.py** -Common methods that can used by both Triangles and Estimators 15 |
**correlation.py** - Mack correlation tests 16 | -------------------------------------------------------------------------------- /chainladder/core/__init__.py: -------------------------------------------------------------------------------- 1 | from chainladder.core.triangle import Triangle # noqa (API import) 2 | from chainladder.core.correlation import ( 3 | DevelopmentCorrelation, 4 | ValuationCorrelation, 5 | ) # noqa (API import) 6 | -------------------------------------------------------------------------------- /chainladder/core/io.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | import pandas as pd 5 | from sklearn.base import BaseEstimator 6 | import json 7 | import joblib 8 | import dill 9 | 10 | 11 | class TriangleIO: 12 | def to_pickle(self, path, protocol=None): 13 | """ Serializes triangle object to pickle. 14 | 15 | Parameters 16 | ---------- 17 | path : str 18 | File path and name of pickle object. 19 | protocol : 20 | The pickle protocol to use. 21 | 22 | """ 23 | with open(path, "wb") as pkl: 24 | dill.dump(self, pkl) 25 | 26 | def to_json(self): 27 | """ Serializes triangle object to json format 28 | 29 | Returns 30 | ------- 31 | string representation of object in json format 32 | """ 33 | metadata = { 34 | "is_val_tri": self.is_val_tri, 35 | "is_cumulative": self.is_cumulative, 36 | "is_pattern": self.is_pattern, 37 | "columns": list(self.columns), 38 | } 39 | out = self.cum_to_incr().dev_to_val().to_frame( 40 | keepdims=True, origin_as_datetime=True).fillna(0) 41 | x = out.reset_index().to_json(orient="split", date_unit="ns") 42 | json_dict = {"metadata": json.dumps(metadata), "data": x} 43 | sub_tris = [k for k, v in vars(self).items() if isinstance(v, TriangleIO)] 44 | json_dict["sub_tris"] = { 45 | sub_tri: getattr(self, sub_tri).to_json() for sub_tri in sub_tris 46 | } 47 | dfs = [k for k, v in vars(self).items() if isinstance(v, pd.DataFrame)] 48 | json_dict["dfs"] = {df: getattr(self, df).to_json() for df in dfs} 49 | dfs = [k for k, v in vars(self).items() if isinstance(v, pd.Series)] 50 | json_dict["dfs"].update( 51 | {df: getattr(self, df).to_frame().to_json() for df in dfs} 52 | ) 53 | return json.dumps(json_dict) 54 | 55 | 56 | class EstimatorIO: 57 | """ Class intended to allow persistence of estimator objects """ 58 | 59 | def to_pickle(self, path, protocol=None): 60 | """ Serializes triangle object to pickle. 61 | 62 | Parameters 63 | ---------- 64 | path : str 65 | File path and name of pickle object. 66 | protocol : 67 | The pickle protocol to use. 68 | """ 69 | with open(path, "wb") as pkl: 70 | dill.dump(self, pkl) 71 | 72 | def to_json(self): 73 | """ Serializes triangle object to json format 74 | 75 | Returns 76 | ------- 77 | string representation of object in json format 78 | """ 79 | params = self.get_params(deep=False) 80 | j = lambda v: v.to_json() if isinstance(v, BaseEstimator) else v 81 | params = {k: j(v) for k, v in params.items()} 82 | return json.dumps({"params": params, "__class__": self.__class__.__name__}) 83 | -------------------------------------------------------------------------------- /chainladder/core/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/chainladder/core/tests/__init__.py -------------------------------------------------------------------------------- /chainladder/core/tests/rtest_correlation.py: -------------------------------------------------------------------------------- 1 | ### Building out a dev environment with a working copy 2 | ### of R ChainLadder is difficult. These tests are 3 | ### Currently inactive, but available should the compatibility 4 | ### of the installs improve at a later date. 5 | 6 | import numpy as np 7 | import pytest 8 | import chainladder as cl 9 | 10 | try: 11 | from rpy2.robjects.packages import importr 12 | from rpy2.robjects import r 13 | CL = importr("ChainLadder") 14 | except: 15 | pass 16 | 17 | def dev_corr_r(data, ci): 18 | return r("out<-dfCorTest({},ci={})".format(data, ci)) 19 | 20 | 21 | @pytest.mark.r 22 | def val_corr_r(data, ci): 23 | return r("out<-cyEffTest({},ci={})".format(data, ci)) 24 | 25 | 26 | def val_corr_p(data, ci): 27 | return cl.load_sample(data).valuation_correlation(p_critical=ci, total=True) 28 | 29 | 30 | data = ["RAA", "GenIns", "MW2014"] 31 | ci = [0.5, 0.75] 32 | 33 | 34 | @pytest.mark.r 35 | @pytest.mark.parametrize("data", data) 36 | @pytest.mark.parametrize("ci", ci) 37 | def test_dev_corr(data, ci, atol): 38 | p = dev_corr_p(data, ci) 39 | r = dev_corr_r(data, ci).rx("T_stat")[0] 40 | p = p.t_expectation.values[0] 41 | assert np.allclose(r, p, atol=atol) 42 | 43 | 44 | @pytest.mark.r 45 | @pytest.mark.parametrize("data", data) 46 | @pytest.mark.parametrize("ci", ci) 47 | def test_dev_corr_var(data, ci, atol): 48 | p = dev_corr_p(data, ci) 49 | r = dev_corr_r(data, ci).rx("Var")[0] 50 | p = np.array([p.t_variance]) 51 | assert np.allclose(r, p, atol=atol) 52 | 53 | 54 | @pytest.mark.r 55 | @pytest.mark.parametrize("data", data) 56 | @pytest.mark.parametrize("ci", ci) 57 | def test_dev_corr_range(data, ci, atol): 58 | p = dev_corr_p(data, 1 - ci) 59 | r = dev_corr_r(data, ci).rx("Range")[0] 60 | p = np.array(p.range) 61 | assert np.allclose(r, p, atol=atol) 62 | 63 | 64 | @pytest.mark.r 65 | @pytest.mark.parametrize("data", data) 66 | @pytest.mark.parametrize("ci", ci) 67 | def test_val_corr_z(data, ci, atol): 68 | p = val_corr_p(data, ci) 69 | r = val_corr_r(data, ci).rx("Z")[0] 70 | p = p.z.values[0] 71 | assert np.allclose(r, p, atol=atol) 72 | 73 | 74 | @pytest.mark.r 75 | @pytest.mark.parametrize("data", data) 76 | @pytest.mark.parametrize("ci", ci) 77 | def test_val_corr_e(data, ci, atol): 78 | p = val_corr_p(data, ci) 79 | r = val_corr_r(data, ci).rx("E")[0] 80 | p = p.z_expectation.values[0] 81 | assert np.allclose(r, p, atol=atol) 82 | 83 | 84 | @pytest.mark.r 85 | @pytest.mark.parametrize("data", data) 86 | @pytest.mark.parametrize("ci", ci) 87 | def test_val_corr_var(data, ci, atol): 88 | p = val_corr_p(data, ci) 89 | r = val_corr_r(data, ci).rx("Var")[0] 90 | p = p.z_variance.values[0] 91 | assert np.allclose(r, p, atol=atol) 92 | -------------------------------------------------------------------------------- /chainladder/core/tests/test_arithmetic.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | def test_arithmetic_union(raa): 5 | assert raa.shape == (raa - raa[raa.valuation < "1987"]).shape 6 | assert raa[raa.valuation<'1986'] + raa[raa.valuation>='1986'] == raa 7 | 8 | 9 | def test_arithmetic_across_keys(qtr): 10 | assert (qtr.sum(1) - qtr.iloc[:, 0]) == qtr.iloc[:, 1] 11 | 12 | 13 | def test_arithmetic_1(raa): 14 | x = raa 15 | assert -(((x / x) + 0) * x) == -(+x) 16 | assert 1 - (x / x) == 0 * x * 0 17 | 18 | 19 | def test_rtruediv(raa): 20 | xp = raa.get_array_module() 21 | assert xp.nansum(abs(((1 / raa) * raa).values[0, 0] - raa.nan_triangle)) < 0.00001 22 | 23 | 24 | def test_vector_division(raa): 25 | raa.latest_diagonal / raa 26 | 27 | 28 | def test_multiindex_broadcast(clrd): 29 | clrd = clrd["CumPaidLoss"] 30 | clrd / clrd.groupby("LOB").sum() 31 | 32 | 33 | def test_index_broadcasting(clrd): 34 | """ Basic broadcasting where b is a subset of a """ 35 | assert ((clrd / clrd.sum()) - ((1 / clrd.sum()) * clrd)).sum().sum().sum() < 1e-4 36 | 37 | def test_index_broadcasting2(clrd): 38 | """ b.key_labels are a subset of a.key_labels and b is missing some elements """ 39 | a = clrd['CumPaidLoss'] 40 | b = clrd['CumPaidLoss'].groupby('LOB').sum().iloc[:-1] 41 | c = a + b 42 | assert (a.index == c.index).all().all() 43 | 44 | 45 | def test_index_broadcasting3(clrd): 46 | """ b.key_labels are a subset of a.key_labels and a is missing some elements """ 47 | a = clrd[~clrd['LOB'].isin(['wkcomp', 'medmal'])]['CumPaidLoss'] 48 | b = clrd['CumPaidLoss'].groupby('LOB').sum() 49 | c = a + b 50 | assert (a.index == c[~c['LOB'].isin(['wkcomp', 'medmal'])].index).all().all() 51 | assert len(c) - len(a) == 2 52 | 53 | 54 | def test_index_broadcasting4(clrd): 55 | """ b should broadcast to a if b only has one index element """ 56 | a = clrd['CumPaidLoss'] 57 | b = clrd['CumPaidLoss'].groupby('LOB').sum().iloc[0] 58 | c = a + b 59 | assert (a.index == c.index).all().all() 60 | 61 | 62 | @pytest.mark.xfail 63 | def test_index_broadacsting4(clrd): 64 | """ If one triangle has key_labels that are not a subset of the other, then fail """ 65 | a = clrd['CumPaidLoss'] 66 | b = clrd['CumPaidLoss'].groupby('LOB').sum() 67 | idx = b.index 68 | idx['New Field'] = 'New' 69 | b.index = idx 70 | c = a + b 71 | 72 | def test_index_broadcasting5(clrd): 73 | """ If a and b have shared key labels but no matching levels, then they will stack """ 74 | a = clrd['CumPaidLoss'].iloc[:300] 75 | b = clrd['CumPaidLoss'].iloc[300:] 76 | c = a + b 77 | assert c.sort_index() == clrd['CumPaidLoss'].sort_index() 78 | 79 | 80 | def test_index_broadacsting6(clrd): 81 | a = clrd['CumPaidLoss'].iloc[:100] 82 | b = clrd['CumPaidLoss'].iloc[50:150] 83 | c = clrd['CumPaidLoss'].iloc[50:100] 84 | d = a + b - c 85 | assert d.sort_index() == clrd['CumPaidLoss'].iloc[:150].sort_index() 86 | -------------------------------------------------------------------------------- /chainladder/core/tests/test_correlation.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | 3 | 4 | def val_corr_p(data, ci): 5 | return cl.load_sample(data).valuation_correlation(p_critical=ci, total=True) -------------------------------------------------------------------------------- /chainladder/core/tests/test_display.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import chainladder as cl 3 | 4 | 5 | def test_heatmap_render(raa): 6 | """The heatmap method should render correctly given the sample.""" 7 | try: 8 | raa.heatmap() 9 | 10 | except: 11 | assert False 12 | 13 | 14 | # def test_empty_triangle(): 15 | # assert cl.Triangle() 16 | 17 | 18 | def test_to_frame(raa): 19 | try: 20 | cl.Chainladder().fit(raa).cdf_.to_frame() 21 | cl.Chainladder().fit(raa).cdf_.to_frame(origin_as_datetime=False) 22 | cl.Chainladder().fit(raa).cdf_.to_frame(origin_as_datetime=True) 23 | cl.Chainladder().fit(raa).ultimate_.to_frame() 24 | cl.Chainladder().fit(raa).ultimate_.to_frame(origin_as_datetime=False) 25 | cl.Chainladder().fit(raa).ultimate_.to_frame(origin_as_datetime=True) 26 | 27 | except: 28 | assert False 29 | 30 | 31 | def test_labels(xyz): 32 | assert ( 33 | xyz.valuation_date.strftime("%Y-%m-%d %H:%M:%S.%f") 34 | == "2008-12-31 23:59:59.999999" 35 | ) 36 | assert xyz.origin_grain == "Y" 37 | assert xyz.development_grain == "Y" 38 | assert xyz.shape == (1, 5, 11, 11) 39 | assert xyz.index_label == ["Total"] 40 | assert xyz.columns_label == ["Incurred", "Paid", "Reported", "Closed", "Premium"] 41 | assert xyz.origin_label == ["AccidentYear"] 42 | -------------------------------------------------------------------------------- /chainladder/development/__init__.py: -------------------------------------------------------------------------------- 1 | from chainladder.development.base import DevelopmentBase # noqa (API import) 2 | from chainladder.development.development import Development # noqa (API import) 3 | from chainladder.development.munich import MunichAdjustment # noqa (API import) 4 | from chainladder.development.incremental import IncrementalAdditive # noqa (API import) 5 | from chainladder.development.constant import DevelopmentConstant # noqa (API import) 6 | from chainladder.development.clark import ClarkLDF # noqa (API import) 7 | from chainladder.development.outstanding import CaseOutstanding # noqa (API import) 8 | from chainladder.development.learning import DevelopmentML # noqa (API import) 9 | from chainladder.development.glm import TweedieGLM # noqa (API import) 10 | from chainladder.development.barnzehn import BarnettZehnwirth # noqa (API import) 11 | -------------------------------------------------------------------------------- /chainladder/development/barnzehn.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | import numpy as np 6 | import pandas as pd 7 | from chainladder import options 8 | from chainladder.development.learning import DevelopmentML 9 | from chainladder.development.glm import TweedieGLM 10 | from sklearn.linear_model import LinearRegression 11 | from sklearn.pipeline import Pipeline 12 | from chainladder.utils.utility_functions import PatsyFormula 13 | 14 | 15 | class BarnettZehnwirth(TweedieGLM): 16 | """ This estimator enables modeling from the Probabilistic Trend Family as 17 | described by Barnett and Zehnwirth. 18 | 19 | .. versionadded:: 0.8.2 20 | 21 | Parameters 22 | ---------- 23 | formula: formula-like 24 | A patsy formula describing the independent variables, X of the GLM 25 | response: str 26 | Column name for the reponse variable of the GLM. If ommitted, then the 27 | first column of the Triangle will be used. 28 | 29 | 30 | """ 31 | 32 | def __init__(self, formula='origin + development + valuation', response=None): 33 | self.formula = formula 34 | self.response = response 35 | 36 | def fit(self, X, y=None, sample_weight=None): 37 | if max(X.shape[:2]) > 1: 38 | raise ValueError("Only single index/column triangles are supported") 39 | tri = X.cum_to_incr().log() 40 | response = X.columns[0] if not self.response else self.response 41 | self.model_ = DevelopmentML(Pipeline(steps=[ 42 | ('design_matrix', PatsyFormula(self.formula)), 43 | ('model', LinearRegression(fit_intercept=False))]), 44 | y_ml=response, fit_incrementals=False).fit(tri) 45 | resid = tri - self.model_.triangle_ml_[ 46 | self.model_.triangle_ml_.valuation <= tri.valuation_date] 47 | self.mse_resid_ = (resid**2).sum(0).sum(1).sum(2).sum() / ( 48 | np.nansum(tri.nan_triangle) - 49 | len(self.model_.estimator_ml.named_steps.model.coef_)) 50 | self.std_residuals_ = (resid / np.sqrt(self.mse_resid_)) 51 | self.model_.triangle_ml_ = self.model_.triangle_ml_.exp() 52 | self.model_.triangle_ml_.is_cumulative = False 53 | return self 54 | 55 | def transform(self, X): 56 | """ If X and self are of different shapes, align self to X, else 57 | return self. 58 | 59 | Parameters 60 | ---------- 61 | X : Triangle 62 | The triangle to be transformed 63 | 64 | Returns 65 | ------- 66 | X_new : New triangle with transformed attributes. 67 | """ 68 | X_new = X.copy() 69 | X_ml = self.model_._prep_X_ml(X.cum_to_incr().log()) 70 | y_ml = self.model_.estimator_ml.predict(X_ml) 71 | triangle_ml = self.model_._get_triangle_ml(X_ml, y_ml) 72 | backend = "cupy" if X.array_backend == "cupy" else "numpy" 73 | triangle_ml.is_cumulative = False 74 | X_new.ldf_ = triangle_ml.exp().incr_to_cum().link_ratio.set_backend(backend) 75 | X_new.ldf_.valuation_date = pd.to_datetime(options.ULT_VAL) 76 | X_new._set_slicers() 77 | return X_new 78 | -------------------------------------------------------------------------------- /chainladder/development/tests/rtest_clark.py: -------------------------------------------------------------------------------- 1 | ### Building out a dev environment with a working copy 2 | ### of R ChainLadder is difficult. These tests are 3 | ### Currently inactive, but available should the compatibility 4 | ### of the installs improve at a later date. 5 | 6 | import numpy as np 7 | import chainladder as cl 8 | import pytest 9 | 10 | try: 11 | from rpy2.robjects.packages import importr 12 | from rpy2.robjects import r 13 | CL = importr("ChainLadder") 14 | except: 15 | pass 16 | 17 | @pytest.mark.r 18 | def test_clarkldf(genins): 19 | model = cl.ClarkLDF().fit(genins) 20 | df = r("ClarkLDF(GenIns)").rx("THETAG") 21 | r_omega = df[0][0] 22 | r_theta = df[0][1] 23 | assert abs(model.omega_.iloc[0, 0] - r_omega) < 1e-2 24 | assert abs(model.theta_.iloc[0, 0] / 12 - r_theta) < 1e-2 25 | 26 | @pytest.mark.r 27 | def test_clarkldf_weibull(genins): 28 | model = cl.ClarkLDF(growth="weibull").fit(genins) 29 | df = r('ClarkLDF(GenIns, G="weibull")').rx("THETAG") 30 | r_omega = df[0][0] 31 | r_theta = df[0][1] 32 | assert abs(model.omega_.iloc[0, 0] - r_omega) < 1e-2 33 | assert abs(model.theta_.iloc[0, 0] / 12 - r_theta) < 1e-2 34 | 35 | @pytest.mark.r 36 | def test_clarkcapecod(genins): 37 | df = r("ClarkCapeCod(GenIns, Premium=10000000+400000*0:9)") 38 | r_omega = df.rx("THETAG")[0][0] 39 | r_theta = df.rx("THETAG")[0][1] 40 | r_elr = df.rx("ELR")[0][0] 41 | premium = genins.latest_diagonal * 0 + 1 42 | premium.values = (np.arange(10) * 400000 + 10000000)[None, None, :, None] 43 | model = cl.ClarkLDF().fit(genins, sample_weight=premium) 44 | assert abs(model.omega_.iloc[0, 0] - r_omega) < 1e-2 45 | assert abs(model.theta_.iloc[0, 0] / 12 - r_theta) < 1e-2 46 | assert abs(model.elr_.iloc[0, 0] - r_elr) < 1e-2 47 | 48 | @pytest.mark.r 49 | def test_clarkcapcod_weibull(genins): 50 | df = r('ClarkCapeCod(GenIns, Premium=10000000+400000*0:9, G="weibull")') 51 | r_omega = df.rx("THETAG")[0][0] 52 | r_theta = df.rx("THETAG")[0][1] 53 | r_elr = df.rx("ELR")[0][0] 54 | premium = genins.latest_diagonal * 0 + 1 55 | premium.values = (np.arange(10) * 400000 + 10000000)[None, None, :, None] 56 | model = cl.ClarkLDF(growth="weibull").fit(genins, sample_weight=premium) 57 | assert abs(model.omega_.iloc[0, 0] - r_omega) < 1e-2 58 | assert abs(model.theta_.iloc[0, 0] / 12 - r_theta) < 1e-2 59 | assert abs(model.elr_.iloc[0, 0] - r_elr) < 1e-2 60 | -------------------------------------------------------------------------------- /chainladder/development/tests/rtest_development.py: -------------------------------------------------------------------------------- 1 | ### Building out a dev environment with a working copy 2 | ### of R ChainLadder is difficult. These tests are 3 | ### Currently inactive, but available should the compatibility 4 | ### of the installs improve at a later date. 5 | 6 | import numpy as np 7 | import pytest 8 | import chainladder as cl 9 | 10 | try: 11 | from rpy2.robjects.packages import importr 12 | from rpy2.robjects import r 13 | 14 | CL = importr("ChainLadder") 15 | except: 16 | pass 17 | 18 | 19 | def mack_r(data, alpha, est_sigma): 20 | return r( 21 | 'mack<-MackChainLadder({},alpha={}, est.sigma="{}")'.format( 22 | data, alpha, est_sigma 23 | ) 24 | ) 25 | 26 | 27 | def mack_p(data, average, est_sigma): 28 | return cl.Development(average=average, sigma_interpolation=est_sigma).fit_transform( 29 | cl.load_sample(data) 30 | ) 31 | 32 | 33 | data = ["RAA", "GenIns", "MW2014"] 34 | averages = [("simple", 0), ("volume", 1), ("regression", 2)] 35 | est_sigma = [("mack", "Mack"), ("log-linear", "log-linear")] 36 | 37 | 38 | 39 | 40 | @pytest.mark.r 41 | @pytest.mark.parametrize("data", data) 42 | @pytest.mark.parametrize("averages", averages) 43 | @pytest.mark.parametrize("est_sigma", est_sigma) 44 | def test_mack_ldf(data, averages, est_sigma, atol): 45 | p = mack_p(data, averages[0], est_sigma[0]).ldf_ 46 | xp = p.get_array_module() 47 | r = xp.array(mack_r(data, averages[1], est_sigma[1]).rx("f"))[:, :-1] 48 | assert xp.allclose(r, p.values[0, 0, :, :], atol=atol) 49 | 50 | 51 | @pytest.mark.r 52 | @pytest.mark.parametrize("data", data) 53 | @pytest.mark.parametrize("averages", averages) 54 | @pytest.mark.parametrize("est_sigma", est_sigma) 55 | def test_mack_sigma(data, averages, est_sigma, atol): 56 | p = mack_p(data, averages[0], est_sigma[0]).sigma_.set_backend( 57 | "numpy", inplace=True 58 | ) 59 | xp = p.get_array_module() 60 | r = xp.array(mack_r(data, averages[1], est_sigma[1]).rx("sigma")) 61 | assert xp.allclose(r, p.values[0, 0, :, :], atol=atol) 62 | 63 | 64 | @pytest.mark.r 65 | @pytest.mark.parametrize("data", data) 66 | @pytest.mark.parametrize("averages", averages) 67 | @pytest.mark.parametrize("est_sigma", est_sigma) 68 | def test_mack_std_err(data, averages, est_sigma, atol): 69 | p = mack_p(data, averages[0], est_sigma[0]).std_err_ 70 | xp = p.get_array_module() 71 | r = xp.array(mack_r(data, averages[1], est_sigma[1]).rx("f.se")) 72 | assert xp.allclose(r, p.values[0, 0, :, :], atol=atol) 73 | -------------------------------------------------------------------------------- /chainladder/development/tests/rtest_munich.py: -------------------------------------------------------------------------------- 1 | ### Building out a dev environment with a working copy 2 | ### of R ChainLadder is difficult. These tests are 3 | ### Currently inactive, but available should the compatibility 4 | ### of the installs improve at a later date. 5 | 6 | import numpy as np 7 | import chainladder as cl 8 | import pytest 9 | 10 | try: 11 | from rpy2.robjects.packages import importr 12 | from rpy2.robjects import r 13 | CL = importr("ChainLadder") 14 | except: 15 | pass 16 | 17 | 18 | @pytest.mark.r 19 | def test_mcl_paid(): 20 | df = r("MunichChainLadder(MCLpaid, MCLincurred)").rx("MCLPaid") 21 | p = cl.MunichAdjustment(paid_to_incurred=("paid", "incurred")).fit( 22 | cl.Development(sigma_interpolation="mack").fit_transform(cl.load_sample("mcl")) 23 | ) 24 | xp = p.ldf_.get_array_module() 25 | arr = xp.array(df[0]) 26 | assert xp.allclose(arr, p.munich_full_triangle_[0, 0, 0, :, :], atol=1e-5) 27 | 28 | 29 | @pytest.mark.r 30 | def test_mcl_incurred(): 31 | df = r("MunichChainLadder(MCLpaid, MCLincurred)").rx("MCLIncurred") 32 | p = cl.MunichAdjustment(paid_to_incurred=[("paid", "incurred")]).fit( 33 | cl.Development(sigma_interpolation="mack").fit_transform(cl.load_sample("mcl")) 34 | ) 35 | xp = p.ldf_.get_array_module() 36 | arr = xp.array(df[0]) 37 | assert xp.allclose(arr, p.munich_full_triangle_[1, 0, 0, :, :], atol=1e-5) -------------------------------------------------------------------------------- /chainladder/development/tests/test_constant.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import numpy as np 3 | import pandas as pd 4 | 5 | 6 | def test_constant_cdf(raa): 7 | dev = cl.Development().fit(raa) 8 | xp = dev.ldf_.get_array_module() 9 | link_ratios = { 10 | (num + 1) * 12: item for num, item in enumerate(dev.ldf_.values[0, 0, 0, :]) 11 | } 12 | dev_c = cl.DevelopmentConstant(patterns=link_ratios, style="ldf").fit(raa) 13 | assert xp.allclose(dev.cdf_.values, dev_c.cdf_.values, atol=1e-5) 14 | 15 | 16 | def test_constant_ldf(raa): 17 | dev = cl.Development().fit(raa) 18 | xp = dev.ldf_.get_array_module() 19 | link_ratios = { 20 | (num + 1) * 12: item for num, item in enumerate(dev.ldf_.values[0, 0, 0, :]) 21 | } 22 | dev_c = cl.DevelopmentConstant(patterns=link_ratios, style="ldf").fit(raa) 23 | assert xp.allclose(dev.ldf_.values, dev_c.ldf_.values, atol=1e-5) 24 | 25 | def test_constant_callable(clrd, atol): 26 | agway = clrd.loc['Agway Ins Co', 'CumPaidLoss'] 27 | def paid_cdfs(x): 28 | """ A function that returns different CDFs depending on a specified LOB """ 29 | cdfs = { 30 | 'comauto': [3.832, 1.874, 1.386, 1.181, 1.085, 1.043, 1.022, 1.013, 1.007, 1], 31 | 'medmal': [24.168, 4.127, 2.103, 1.528, 1.275, 1.161, 1.088, 1.047, 1.018, 1], 32 | 'othliab': [10.887, 3.416, 1.957, 1.433, 1.231, 1.119, 1.06, 1.031, 1.011, 1], 33 | 'ppauto': [2.559, 1.417, 1.181, 1.084, 1.04, 1.019, 1.009, 1.004, 1.001, 1], 34 | 'prodliab': [13.703, 5.613, 2.92, 1.765, 1.385, 1.177, 1.072, 1.034, 1.008, 1], 35 | 'wkcomp': [4.106, 1.865, 1.418, 1.234, 1.141, 1.09, 1.056, 1.03, 1.01, 1]} 36 | patterns = pd.DataFrame(cdfs, index=range(12, 132, 12)).T 37 | return patterns.loc[x.loc['LOB']].to_dict() 38 | model = cl.DevelopmentConstant(patterns=paid_cdfs, callable_axis=1, style='cdf') 39 | assert abs(model.fit_transform(agway).cdf_.loc['comauto'].iloc[..., 0].sum() - 3.832) < atol 40 | -------------------------------------------------------------------------------- /chainladder/development/tests/test_glm.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | 3 | def test_basic_odp_cl(genins): 4 | assert abs( 5 | (cl.Chainladder().fit(genins).ultimate_ - 6 | cl.Chainladder().fit(cl.TweedieGLM().fit_transform(genins)).ultimate_) / 7 | genins.latest_diagonal).max()< 1e-2 8 | -------------------------------------------------------------------------------- /chainladder/development/tests/test_incremental.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import numpy as np 3 | 4 | 5 | def test_schmidt(): 6 | tri = cl.load_sample("ia_sample") 7 | xp = np if tri.array_backend == "sparse" else tri.get_array_module() 8 | ia = cl.IncrementalAdditive() 9 | ia_transform = ia.fit_transform( 10 | tri.iloc[0, 0], sample_weight=tri.iloc[0, 1].latest_diagonal 11 | ) 12 | answer = ia_transform.incremental_.incr_to_cum().values[0, 0, :, -1] 13 | answer_zeta = ia_transform.zeta_.values[0,0,0,:] 14 | answer_cum_zeta = ia_transform.cum_zeta_.values[0,0,0,:] 15 | check = xp.array( 16 | [ 17 | 3483.0, 18 | 4007.84795031, 19 | 4654.36196862, 20 | 5492.00685523, 21 | 6198.10197128, 22 | 7152.82539296, 23 | ] 24 | ) 25 | check_zeta = xp.array( 26 | [ 27 | 0.24321225, 28 | 0.22196026, 29 | 0.15397836, 30 | 0.14185271, 31 | 0.09067327, 32 | 0.03677019 33 | ] 34 | ) 35 | check_cum_zeta = xp.array( 36 | [ 37 | 0.88844704, 38 | 0.64523479, 39 | 0.42327453, 40 | 0.26929617, 41 | 0.12744346, 42 | 0.03677019 43 | ] 44 | ) 45 | assert xp.allclose(answer, check, atol=1e-5) & xp.allclose(answer_zeta, check_zeta, atol=1e-8) & xp.allclose(answer_cum_zeta, check_cum_zeta, atol=1e-8) 46 | 47 | def test_IBNR_methods(): 48 | tri = cl.load_sample("ia_sample") 49 | incr_est = cl.IncrementalAdditive().fit(tri['loss'], sample_weight=tri['exposure'].latest_diagonal) 50 | incr_trans = incr_est.transform(tri['loss']) 51 | incr_tri = incr_est.incremental_.incr_to_cum() 52 | incr_ult = incr_tri[incr_tri.development == incr_tri.development.max()] 53 | cl_est = cl.Chainladder().fit(incr_trans) 54 | bf_est = cl.BornhuetterFerguson(apriori=1).fit(incr_trans, sample_weight=incr_ult) 55 | incr_result = np.round(incr_est.incremental_.values,5) 56 | cl_result = np.round(cl_est.full_triangle_.cum_to_incr().values[...,:-2],5) 57 | bf_result = np.round(bf_est.full_triangle_.cum_to_incr().values[...,:-2],5) 58 | assert np.all(incr_result == cl_result) & np.all(incr_result == bf_result) 59 | 60 | def test_pipeline(): 61 | clrd = cl.load_sample("clrd").groupby('LOB')[["IncurLoss","CumPaidLoss"]].sum() 62 | dev = cl.Development().fit_transform(clrd) 63 | ult = cl.Chainladder().fit(clrd) 64 | dev1 = cl.IncrementalAdditive( 65 | n_periods = 7, 66 | drop_valuation = 1995, 67 | drop = ("1992",12), 68 | drop_above = 1.05, 69 | drop_below = -1, 70 | drop_high = 1, 71 | drop_low = 1 72 | ).fit(clrd,sample_weight = ult.ultimate_ * 3) 73 | pipe = cl.Pipeline(steps=[ 74 | ('n_periods', cl.IncrementalAdditive(n_periods = 7)), 75 | ('drop_valuation', cl.IncrementalAdditive(drop_valuation = 1995)), 76 | ('drop', cl.IncrementalAdditive(drop = ("1992",12))), 77 | ('drop_abovebelow', cl.IncrementalAdditive(drop_above = 1.05, drop_below = .95)), 78 | ('drop_hilo', cl.IncrementalAdditive(drop_high = 1, drop_low = 1))] 79 | ) 80 | dev2 = pipe.fit(X=clrd,sample_weight=ult.ultimate_ * 3) 81 | assert np.array_equal(dev1.zeta_.values,dev2.named_steps.drop_hilo.zeta_.values,True) -------------------------------------------------------------------------------- /chainladder/development/tests/test_munich.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | 3 | 4 | def test_mcl_ult(): 5 | mcl = cl.load_sample("mcl") 6 | dev = cl.Development().fit_transform(mcl) 7 | cl_traditional = cl.Chainladder().fit(dev).ultimate_ 8 | dev_munich = cl.MunichAdjustment( 9 | paid_to_incurred=[("paid", "incurred")] 10 | ).fit_transform(dev) 11 | cl_munich = cl.Chainladder().fit(dev_munich).ultimate_ 12 | 13 | 14 | def test_mcl_rollforward(): 15 | mcl = cl.load_sample("mcl") 16 | mcl_prior = mcl[mcl.valuation < mcl.valuation_date] 17 | munich = cl.MunichAdjustment(paid_to_incurred=[("paid", "incurred")]).fit(mcl_prior) 18 | new = munich.transform(mcl) 19 | cl.Chainladder().fit(new).ultimate_ 20 | -------------------------------------------------------------------------------- /chainladder/development/tests/test_outstanding.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import numpy as np 3 | 4 | 5 | def test_basic_case_outstanding(): 6 | tri = cl.load_sample("usauto") 7 | m = cl.CaseOutstanding(paid_to_incurred=("paid", "incurred")).fit(tri) 8 | out = cl.Chainladder().fit(m.fit_transform(tri)) 9 | a = (out.full_triangle_["incurred"] - out.full_triangle_["paid"]).iloc[ 10 | ..., -1, :9 11 | ] * m.paid_ldf_.values 12 | b = (out.full_triangle_["paid"].cum_to_incr().iloc[..., -1, 1:10]).values 13 | assert (a - b).max() < 1e-6 14 | 15 | 16 | def test_outstanding_friedland_example(): 17 | usauto = cl.load_sample("usauto") 18 | model = cl.CaseOutstanding( 19 | paid_to_incurred=("paid", "incurred"), paid_n_periods=3, case_n_periods=3 20 | ).fit(usauto) 21 | 22 | expected_paid_ldf = np.array( 23 | [ 24 | [ 25 | 0.833, 26 | 0.701, 27 | 0.714, 28 | 0.714, 29 | 0.653, 30 | 0.631, 31 | 0.553, 32 | 0.437, 33 | 0.524, 34 | ] 35 | ] 36 | ) 37 | assert ( 38 | model.paid_ldf_.to_frame(origin_as_datetime=False).values - expected_paid_ldf 39 | < 0.001 40 | ).all() 41 | 42 | expected_case_ldf = np.array( 43 | [ 44 | [ 45 | 0.526, 46 | 0.566, 47 | 0.528, 48 | 0.486, 49 | 0.511, 50 | 0.555, 51 | 0.652, 52 | 0.674, 53 | 0.580, 54 | ] 55 | ] 56 | ) 57 | assert ( 58 | model.case_ldf_.to_frame(origin_as_datetime=False).values - expected_case_ldf 59 | < 0.001 60 | ).all() 61 | -------------------------------------------------------------------------------- /chainladder/methods/__init__.py: -------------------------------------------------------------------------------- 1 | from chainladder.methods.base import MethodBase # noqa (API import) 2 | from chainladder.methods.chainladder import Chainladder # noqa (API import) 3 | from chainladder.methods.mack import MackChainladder # noqa (API import) 4 | from chainladder.methods.benktander import Benktander # noqa (API import) 5 | from chainladder.methods.bornferg import BornhuetterFerguson # noqa (API import) 6 | from chainladder.methods.capecod import CapeCod # noqa (API import) 7 | from chainladder.methods.expectedloss import ExpectedLoss # noqa (API import) 8 | -------------------------------------------------------------------------------- /chainladder/methods/bornferg.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from chainladder.methods import Benktander 5 | 6 | 7 | class BornhuetterFerguson(Benktander): 8 | """The deterministic Bornhuetter Ferguson IBNR model 9 | 10 | Parameters 11 | ---------- 12 | apriori: float, optional (default=1.0) 13 | Multiplier for the sample_weight used in the Bornhuetter Ferguson 14 | method. If sample_weight is already an apriori measure of ultimate, 15 | then use 1.0 16 | apriori_sigma: float, optional (default=0.0) 17 | Standard deviation of the apriori. When used in conjunction with the 18 | bootstrap model, the model samples aprioris from a lognormal distribution 19 | using this argument as a standard deviation. 20 | random_state: int, RandomState instance or None, optional (default=None) 21 | Seed for sampling from the apriori distribution. This is ignored when 22 | using as a deterministic method. 23 | If int, random_state is the seed used by the random number generator; 24 | If RandomState instance, random_state is the random number generator; 25 | If None, the random number generator is the RandomState instance used 26 | by np.random. 27 | 28 | Attributes 29 | ---------- 30 | ultimate_: Triangle 31 | The ultimate losses per the method 32 | ibnr_: Triangle 33 | The IBNR per the method 34 | """ 35 | 36 | def __init__(self, apriori=1.0, apriori_sigma=0.0, random_state=None): 37 | self.apriori = apriori 38 | self.apriori_sigma = apriori_sigma 39 | self.random_state = random_state 40 | 41 | def fit(self, X, y=None, sample_weight=None): 42 | """Applies the Bornhuetter-Ferguson technique to triangle **X** 43 | 44 | Parameters 45 | ---------- 46 | X : Triangle 47 | Loss data to which the model will be applied. 48 | y : None 49 | Ignored 50 | sample_weight : Triangle 51 | Required exposure to be used in the calculation. 52 | 53 | Returns 54 | ------- 55 | self : object 56 | Returns the instance itself. 57 | """ 58 | self.n_iters = 1 59 | super().fit(X, y, sample_weight) 60 | return self 61 | 62 | def predict(self, X, sample_weight=None): 63 | """Predicts the Bornhuetter-Ferguson ultimate on a new triangle **X** 64 | 65 | Parameters 66 | ---------- 67 | X : Triangle 68 | Loss data to which the model will be applied. 69 | sample_weight : Triangle 70 | Required exposure to be used in the calculation. 71 | 72 | Returns 73 | ------- 74 | X_new: Triangle 75 | Loss data with Bornhuetter-Ferguson ultimate applied 76 | """ 77 | return super().predict(X, sample_weight) 78 | -------------------------------------------------------------------------------- /chainladder/methods/chainladder.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from chainladder.methods import MethodBase 5 | 6 | 7 | class Chainladder(MethodBase): 8 | """ 9 | The basic deterministic chainladder method. 10 | 11 | Parameters 12 | ---------- 13 | None 14 | 15 | Attributes 16 | ---------- 17 | X_: 18 | returns **X** used to fit the triangle 19 | ultimate_: 20 | The ultimate losses per the method 21 | ibnr_: 22 | The IBNR per the method 23 | full_expectation_: 24 | The ultimates back-filled to each development period in **X** replacing 25 | the known data 26 | full_triangle_: 27 | The ultimates back-filled to each development period in **X** retaining 28 | the known data 29 | """ 30 | 31 | def fit(self, X, y=None, sample_weight=None): 32 | """Fit the model with X. 33 | 34 | Parameters 35 | ---------- 36 | X: Triangle-like 37 | Data to which the model will be applied. 38 | y: Ignored 39 | sample_weight : Ignored 40 | 41 | Returns 42 | ------- 43 | self: object 44 | Returns the instance itself. 45 | """ 46 | super().fit(X, y, sample_weight) 47 | self.ultimate_ = self._get_ultimate(self.X_) 48 | self.process_variance_ = self._include_process_variance() 49 | return self 50 | 51 | def predict(self, X, sample_weight=None): 52 | """Predicts the chainladder ultimate on a new triangle **X** 53 | 54 | Parameters 55 | ---------- 56 | X: Triangle 57 | Loss data to which the model will be applied. 58 | sample_weight: Triangle 59 | Required exposure to be used in the calculation. 60 | 61 | Returns 62 | ------- 63 | X_new: Triangle 64 | Loss data with chainladder ultimate applied 65 | """ 66 | X_new = super().predict(X, sample_weight) 67 | X_new.ultimate_ = self._get_ultimate(X_new, sample_weight) 68 | return X_new 69 | 70 | def _get_ultimate(self, X, sample_weight=None): 71 | """ Private method that uses CDFs to obtain an ultimate vector """ 72 | if X.is_cumulative == False: 73 | ld = X.sum('development') 74 | ultimate = ld.val_to_dev() 75 | else: 76 | ld = X.latest_diagonal 77 | ultimate = X.copy() 78 | cdf = self._align_cdf(ultimate, sample_weight) 79 | ultimate = ld * cdf 80 | return self._set_ult_attr(ultimate) 81 | -------------------------------------------------------------------------------- /chainladder/methods/expectedloss.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from chainladder.methods import Benktander 5 | 6 | 7 | class ExpectedLoss(Benktander): 8 | """The deterministic Expected Loss IBNR model 9 | 10 | Parameters 11 | ---------- 12 | apriori: float, optional (default=1.0) 13 | Multiplier for the sample_weight used in the Expected Loss 14 | method. If sample_weight is already an apriori measure of ultimate, 15 | then use 1.0 16 | apriori_sigma: float, optional (default=0.0) 17 | Standard deviation of the apriori. When used in conjunction with the 18 | bootstrap model, the model samples aprioris from a lognormal distribution 19 | using this argument as a standard deviation. 20 | random_state: int, RandomState instance or None, optional (default=None) 21 | Seed for sampling from the apriori distribution. This is ignored when 22 | using as a deterministic method. 23 | If int, random_state is the seed used by the random number generator; 24 | If RandomState instance, random_state is the random number generator; 25 | If None, the random number generator is the RandomState instance used 26 | by np.random. 27 | 28 | Attributes 29 | ---------- 30 | ultimate_: Triangle 31 | The ultimate losses per the method 32 | ibnr_: Triangle 33 | The IBNR per the method 34 | """ 35 | 36 | def __init__(self, apriori=1.0, apriori_sigma=0.0, random_state=None): 37 | self.apriori = apriori 38 | self.apriori_sigma = apriori_sigma 39 | self.random_state = random_state 40 | 41 | def fit(self, X, y=None, sample_weight=None): 42 | """Applies the Benktander technique to triangle **X** 43 | 44 | Parameters 45 | ---------- 46 | X : Triangle 47 | Loss data to which the model will be applied. 48 | y : None 49 | Ignored 50 | sample_weight : Triangle 51 | Required exposure to be used in the calculation. 52 | 53 | Returns 54 | ------- 55 | self : object 56 | Returns the instance itself. 57 | """ 58 | self.n_iters = 0 59 | super().fit(X, y, sample_weight) 60 | return self 61 | 62 | def predict(self, X, sample_weight=None): 63 | """Predicts the Benktander ultimate on a new triangle **X** 64 | 65 | Parameters 66 | ---------- 67 | X : Triangle 68 | Loss data to which the model will be applied. 69 | sample_weight : Triangle 70 | Required exposure to be used in the calculation. 71 | 72 | Returns 73 | ------- 74 | X_new: Triangle 75 | Loss data with Bornhuetter-Ferguson ultimate applied 76 | """ 77 | return super().predict(X, sample_weight) 78 | 79 | -------------------------------------------------------------------------------- /chainladder/methods/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/chainladder/methods/tests/__init__.py -------------------------------------------------------------------------------- /chainladder/methods/tests/test_benktander.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import numpy as np 3 | import chainladder as cl 4 | 5 | 6 | @pytest.fixture 7 | def atol(): 8 | return 1e-5 9 | 10 | 11 | data = ["RAA", "ABC", "GenIns", "MW2008", "MW2014"] 12 | 13 | 14 | @pytest.mark.parametrize("data", data) 15 | def test_benktander_to_chainladder(data, atol): 16 | tri = cl.load_sample(data) 17 | a = cl.Chainladder().fit(tri).ibnr_ 18 | b = cl.Benktander(apriori=0.8, n_iters=255).fit(tri, sample_weight=a).ibnr_ 19 | xp = tri.get_array_module() 20 | assert xp.allclose(xp.nan_to_num(a.values), xp.nan_to_num(b.values), atol=atol) 21 | 22 | 23 | def test_bf_eq_cl_when_using_cl_apriori(qtr): 24 | cl_ult = cl.Chainladder().fit(qtr).ultimate_ 25 | bf_ult = cl.BornhuetterFerguson().fit(qtr, sample_weight=cl_ult).ultimate_ 26 | xp = cl_ult.get_array_module() 27 | assert xp.allclose(cl_ult.values, bf_ult.values, atol=1e-5) 28 | 29 | 30 | def test_different_backends(clrd): 31 | clrd = clrd[["CumPaidLoss", "EarnedPremDIR"]] 32 | clrd = clrd[clrd["LOB"] == "wkcomp"] 33 | model = cl.BornhuetterFerguson().fit( 34 | clrd["CumPaidLoss"].sum().set_backend("numpy"), 35 | sample_weight=clrd["EarnedPremDIR"].sum().latest_diagonal.set_backend("numpy"), 36 | ) 37 | assert ( 38 | abs( 39 | ( 40 | model.predict( 41 | clrd["CumPaidLoss"].set_backend("sparse"), 42 | sample_weight=clrd["EarnedPremDIR"].latest_diagonal.set_backend( 43 | "sparse" 44 | ), 45 | ).ibnr_.sum() 46 | - model.ibnr_ 47 | ).sum() 48 | ) 49 | < 1 50 | ) 51 | -------------------------------------------------------------------------------- /chainladder/methods/tests/test_capecod.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import numpy as np 3 | 4 | def test_struhuss(): 5 | X = cl.load_sample("cc_sample")["loss"] 6 | X = cl.TailConstant(tail=1 / 0.85).fit_transform(cl.Development().fit_transform(X)) 7 | sample_weight = cl.load_sample("cc_sample")["exposure"].latest_diagonal 8 | ibnr = int( 9 | cl.CapeCod(trend=0.07, decay=0.75) 10 | .fit(X, sample_weight=sample_weight) 11 | .ibnr_.sum() 12 | ) 13 | assert ibnr == 17052 14 | 15 | 16 | def test_groupby(clrd): 17 | clrd = clrd[clrd['LOB']=='comauto'] 18 | # But only the top 10 get their own CapeCod aprioris. Smaller companies get grouped together 19 | top_10 = clrd['EarnedPremDIR'].groupby('GRNAME').sum().latest_diagonal 20 | top_10 = top_10.loc[..., '1997', :].to_frame(origin_as_datetime=True).nlargest(10) 21 | cc_groupby = clrd.index['GRNAME'].map(lambda x: x if x in top_10.index else 'Remainder') 22 | idx = clrd.index 23 | idx['Top 10'] = cc_groupby 24 | clrd.index = idx 25 | 26 | # All companies share the same development factors regardless of size 27 | X = cl.Development().fit(clrd['CumPaidLoss'].sum()).transform(clrd['CumPaidLoss']) 28 | sample_weight=clrd['EarnedPremDIR'].latest_diagonal 29 | a = cl.CapeCod(groupby='Top 10', decay=0.98, trend=0.02).fit(X, sample_weight=sample_weight).ibnr_.groupby('Top 10').sum().sort_index() 30 | b = cl.CapeCod(decay=0.98, trend=0.02).fit(X.groupby('Top 10').sum(), sample_weight=sample_weight.groupby('Top 10').sum()).ibnr_.sort_index() 31 | xp = a.get_array_module() 32 | b = b.set_backend(a.array_backend) 33 | xp.allclose(xp.nan_to_num(a.values), xp.nan_to_num(b.values), atol=1e-5) 34 | 35 | 36 | def test_capecod_zero_tri(raa): 37 | premium = raa.latest_diagonal * 0 + 50000 38 | raa.loc[:,:,'1987',48] = 0 39 | assert cl.CapeCod().fit(raa, sample_weight=premium).ultimate_.loc[:,:,'1987'].sum() > 0 40 | 41 | 42 | def test_capecod_predict1(prism): 43 | """ github issue #400 44 | Test whether we can make predictions at a more granular level than is fitted 45 | """ 46 | prism = prism[['reportedCount', 'Paid']] 47 | 48 | cc_pipe = cl.Pipeline( 49 | [('dev', cl.Development()), 50 | ('model', cl.CapeCod())] 51 | ) 52 | cc_pipe.fit( 53 | X=prism.groupby('Line')['Paid'].sum(), 54 | sample_weight=prism.groupby('Line')['reportedCount'].sum().sum('development')) 55 | 56 | assert abs(cc_pipe.predict(prism['Paid'], sample_weight=prism['reportedCount'].sum('development')).ultimate_.sum() - 57 | cc_pipe.named_steps.model.ultimate_.sum()).sum() < 1e-6 58 | 59 | 60 | def test_capecod_predict2(prism): 61 | """ github issue #400 62 | Test whether predictions between groupby with estimator and 63 | groupby outside estimator match 64 | """ 65 | prism = prism[['reportedCount', 'Paid']] 66 | 67 | pipe1 = cl.Pipeline( 68 | [('dev', cl.Development(groupby='Line')), 69 | ('model', cl.CapeCod(groupby='Line'))] 70 | ) 71 | pipe1.fit( 72 | X=prism['Paid'], 73 | sample_weight=prism['reportedCount'].sum('development')) 74 | 75 | pipe2 = cl.Pipeline( 76 | [('dev', cl.Development()), 77 | ('model', cl.CapeCod())] 78 | ) 79 | pipe2.fit( 80 | X=prism.groupby('Line')['Paid'].sum(), 81 | sample_weight=prism.groupby('Line')['reportedCount'].sum().sum('development')) 82 | 83 | pred1 = pipe1.named_steps.model.ultimate_.sum() 84 | pred2 = pipe2.predict(prism['Paid'], sample_weight=prism['reportedCount'].sum('development')).ultimate_.sum() 85 | 86 | assert np.nan_to_num(abs(pred1 - pred2).values).sum() <= 1e-6 -------------------------------------------------------------------------------- /chainladder/methods/tests/test_mack.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | 3 | def test_mack_to_triangle(): 4 | assert ( 5 | cl.MackChainladder() 6 | .fit( 7 | cl.TailConstant().fit_transform( 8 | cl.Development().fit_transform(cl.load_sample("ABC")) 9 | ) 10 | ) 11 | .summary_ 12 | == cl.MackChainladder() 13 | .fit(cl.Development().fit_transform(cl.load_sample("ABC"))) 14 | .summary_ 15 | ) 16 | 17 | 18 | def test_mack_malformed(): 19 | a = cl.load_sample('raa') 20 | b = a.iloc[:, :, :-1] 21 | x = cl.MackChainladder().fit(a) 22 | y = cl.MackChainladder().fit(b) 23 | assert x.process_risk_.iloc[:,:,:-1] == y.process_risk_ -------------------------------------------------------------------------------- /chainladder/tails/__init__.py: -------------------------------------------------------------------------------- 1 | """ tails should store all tail methodologies 2 | """ 3 | from chainladder.tails.base import TailBase # noqa (API import) 4 | from chainladder.tails.constant import TailConstant # noqa (API import) 5 | from chainladder.tails.curve import TailCurve # noqa (API import) 6 | from chainladder.tails.bondy import TailBondy # noqa (API import) 7 | from chainladder.tails.clark import TailClark # noqa (API import) 8 | -------------------------------------------------------------------------------- /chainladder/tails/constant.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from chainladder.tails import TailBase 5 | from chainladder.development import Development 6 | 7 | 8 | class TailConstant(TailBase): 9 | """Allows for the entry of a constant tail factor to LDFs. 10 | 11 | Parameters 12 | ---------- 13 | tail: float 14 | The constant to apply to all LDFs within a triangle object. 15 | decay: float (default=0.50) 16 | An exponential decay constant that allows for decay over future 17 | development periods. A decay rate of 0.5 sets the development portion 18 | of each successive LDF to 50% of the previous LDF. 19 | attachment_age: int (default=None) 20 | The age at which to attach the fitted curve. If None, then the latest 21 | age is used. Measures of variability from original ``ldf_`` are retained 22 | when being used in conjunction with the MackChainladder method. 23 | projection_period: int 24 | The number of months beyond the latest available development age the 25 | `ldf_` and `cdf_` vectors should extend. 26 | 27 | Attributes 28 | ---------- 29 | ldf_: 30 | ldf with tail applied. 31 | cdf_: 32 | cdf with tail applied. 33 | tail_: DataFrame 34 | Point estimate of tail at latest maturity available in the Triangle. 35 | 36 | Notes 37 | ----- 38 | The tail constant does not support the entry of variability parameters 39 | necessary for stochastic approaches, so any usage of TailConstant will be 40 | inherently deterministic. 41 | 42 | See also 43 | -------- 44 | TailCurve 45 | 46 | """ 47 | 48 | def __init__(self, tail=1.0, decay=0.5, attachment_age=None, projection_period=12): 49 | self.tail = tail 50 | self.decay = decay 51 | self.attachment_age = attachment_age 52 | self.projection_period = projection_period 53 | 54 | def fit(self, X, y=None, sample_weight=None): 55 | """Fit the model with X. 56 | 57 | Parameters 58 | ---------- 59 | X : Triangle-like 60 | Set of LDFs to which the tail will be applied. 61 | y : Ignored 62 | sample_weight : Ignored 63 | 64 | Returns 65 | ------- 66 | self : object 67 | Returns the instance itself. 68 | """ 69 | super().fit(X, y, sample_weight) 70 | xp = self.ldf_.get_array_module() 71 | tail = self.tail 72 | if self.attachment_age: 73 | attach_idx = xp.min(xp.where(X.ddims >= self.attachment_age)) 74 | else: 75 | attach_idx = len(X.ddims) - 1 76 | self = self._apply_decay(X, tail, attach_idx) 77 | obj = Development().fit_transform(X) if "ldf_" not in X else X 78 | self._get_tail_stats(obj) 79 | return self 80 | -------------------------------------------------------------------------------- /chainladder/tails/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/chainladder/tails/tests/__init__.py -------------------------------------------------------------------------------- /chainladder/tails/tests/test_bondy.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | 3 | 4 | def test_bondy1(): 5 | tri = cl.load_sample("tail_sample")["paid"] 6 | dev = cl.Development(average="simple").fit_transform(tri) 7 | assert round(float(cl.TailBondy(earliest_age=12).fit(dev).cdf_.values[0, 0, 0, -2]), 3) == 1.028 8 | -------------------------------------------------------------------------------- /chainladder/tails/tests/test_constant.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import numpy as np 3 | from chainladder.utils.cupy import cp 4 | 5 | 6 | def test_constant_balances(qtr): 7 | xp = qtr.get_array_module() 8 | assert ( 9 | round( 10 | float( 11 | xp.prod( 12 | cl.TailConstant(1.05, decay=0.8) 13 | .fit(qtr) 14 | .ldf_.iloc[0, 1] 15 | .values[0, 0, 0, -5:] 16 | ) 17 | ), 18 | 3, 19 | ) 20 | == 1.050 21 | ) 22 | -------------------------------------------------------------------------------- /chainladder/tails/tests/test_exponential.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import pytest 3 | 4 | 5 | def test_fit_period(): 6 | tri = cl.load_sample("tail_sample") 7 | dev = cl.Development(average="simple").fit_transform(tri) 8 | assert ( 9 | round( 10 | cl.TailCurve(fit_period=(tri.ddims[-7], None), extrap_periods=10) 11 | .fit(dev) 12 | .cdf_["paid"] 13 | .set_backend("numpy", inplace=True) 14 | .values[0, 0, 0, -2], 15 | 3, 16 | ) 17 | == 1.044 18 | ) 19 | 20 | 21 | def test_curve_validation(): 22 | """ 23 | Test validation of the curve parameter. Should raise a value error if an incorrect argument is supplied. 24 | """ 25 | 26 | with pytest.raises(ValueError): 27 | tri = cl.load_sample('tail_sample') 28 | cl.TailCurve( 29 | curve='Exponential' 30 | ).fit_transform(tri) 31 | 32 | 33 | def test_errors_validation(): 34 | """ 35 | Test validation of the errors parameter. Should raise a value error if an incorrect argument is supplied. 36 | """ 37 | with pytest.raises(ValueError): 38 | tri = cl.load_sample('tail_sample') 39 | cl.TailCurve( 40 | errors='Ignore' 41 | ).fit_transform(tri) 42 | -------------------------------------------------------------------------------- /chainladder/utils/__init__.py: -------------------------------------------------------------------------------- 1 | """ utils should store all utility functions and classes, i.e. things that 2 | are used by various modules in the package. 3 | """ 4 | from chainladder.utils.weighted_regression import ( 5 | WeightedRegression, 6 | ) # noqa (API import) 7 | 8 | from chainladder.utils.utility_functions import ( # noqa (API import) 9 | parallelogram_olf, 10 | read_pickle, 11 | read_json, 12 | concat, 13 | load_sample, 14 | minimum, 15 | maximum, 16 | PatsyFormula, 17 | model_diagnostics 18 | ) 19 | from chainladder.utils.cupy import cp 20 | from chainladder.utils.sparse import sp 21 | from chainladder.utils.dask import dp 22 | -------------------------------------------------------------------------------- /chainladder/utils/cupy.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | import numpy as np 5 | 6 | from chainladder import options 7 | from chainladder.utils.sparse import sp 8 | 9 | try: 10 | import cupy as cp 11 | 12 | cp.array([1]) 13 | module = "cupy" 14 | except: 15 | if options.ARRAY_BACKEND == "cupy": 16 | import warnings 17 | 18 | warnings.warn("Unable to load CuPY. Using numpy instead.") 19 | import numpy as cp 20 | 21 | module = "numpy" 22 | 23 | 24 | def nansum(a, *args, **kwargs): 25 | """ For cupy v0.6.0 compatibility """ 26 | return cp.sum(cp.nan_to_num(a), *args, **kwargs) 27 | 28 | 29 | def nanmean(a, *args, **kwargs): 30 | """ For cupy v0.6.0 compatibility """ 31 | return cp.sum(cp.nan_to_num(a), *args, **kwargs) / cp.sum( 32 | ~cp.isnan(a), *args, **kwargs 33 | ) 34 | 35 | 36 | def nanmedian(a, *args, **kwargs): 37 | """ For cupy v0.6.0 compatibility """ 38 | return cp.array(np.nanmedian(cp.asnumpy(a), *args, **kwargs)) 39 | 40 | 41 | def nanquantile(a, *args, **kwargs): 42 | """ For cupy v0.6.0 compatibility """ 43 | return cp.array(np.nanquantile(cp.asnumpy(a), *args, **kwargs)) 44 | 45 | 46 | def unique(ar, axis=None, *args, **kwargs): 47 | """ For cupy v0.6.0 compatibility """ 48 | return cp.array(np.unique(cp.asnumpy(ar), axis=axis, *args, **kwargs)) 49 | 50 | 51 | if module == "cupy": 52 | if int(cp.__version__.split(".")[0]) < 7: 53 | cp.nansum = nansum 54 | cp.nanmean = nanmean 55 | cp.nanmedian = nanmedian 56 | cp.unique = unique 57 | if int(cp.__version__.split(".")[0]) >= 7: 58 | cp.nanquantile = nanquantile 59 | -------------------------------------------------------------------------------- /chainladder/utils/dask.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | import numpy as np 5 | from chainladder import options 6 | 7 | try: 8 | import dask.array as dp 9 | dp.array([1]) 10 | module = "dask" 11 | except: 12 | if options.ARRAY_BACKEND == "dask": 13 | import warnings 14 | 15 | warnings.warn("Unable to load Dask. Using numpy instead.") 16 | import numpy as dp 17 | module = "numpy" 18 | 19 | dp.nan = np.nan 20 | 21 | 22 | def expand_dims(a, axis=0): 23 | l = [] 24 | for i in range(len(a.shape)): 25 | if i == axis: 26 | l.append(None) 27 | l.append(slice(None)) 28 | return a.__getitem__(tuple(l)) 29 | 30 | if dp != np: 31 | dp.expand_dims = expand_dims 32 | -------------------------------------------------------------------------------- /chainladder/utils/data/abc.csv: -------------------------------------------------------------------------------- 1 | development,origin,values 2 | 1977,1977,153638.0 3 | 1978,1978,178536.0 4 | 1979,1979,210172.0 5 | 1980,1980,211448.0 6 | 1981,1981,219810.0 7 | 1982,1982,205654.0 8 | 1983,1983,197716.0 9 | 1984,1984,239784.0 10 | 1985,1985,326304.0 11 | 1986,1986,420778.0 12 | 1987,1987,496200.0 13 | 1978,1977,342050.0 14 | 1979,1978,404948.0 15 | 1980,1979,469340.0 16 | 1981,1980,464930.0 17 | 1982,1981,486114.0 18 | 1983,1982,458400.0 19 | 1984,1983,453124.0 20 | 1985,1984,569026.0 21 | 1986,1985,798048.0 22 | 1987,1986,1011178.0 23 | 1979,1977,476584.0 24 | 1980,1978,563842.0 25 | 1981,1979,657728.0 26 | 1982,1980,648300.0 27 | 1983,1981,680764.0 28 | 1984,1982,635906.0 29 | 1985,1983,647772.0 30 | 1986,1984,833828.0 31 | 1987,1985,1173448.0 32 | 1980,1977,564040.0 33 | 1981,1978,668528.0 34 | 1982,1979,780802.0 35 | 1983,1980,779340.0 36 | 1984,1981,800862.0 37 | 1985,1982,765428.0 38 | 1986,1983,790100.0 39 | 1987,1984,1024228.0 40 | 1981,1977,624388.0 41 | 1982,1978,739976.0 42 | 1983,1979,864182.0 43 | 1984,1980,858334.0 44 | 1985,1981,888444.0 45 | 1986,1982,862214.0 46 | 1987,1983,895700.0 47 | 1982,1977,666792.0 48 | 1983,1978,787966.0 49 | 1984,1979,920268.0 50 | 1985,1980,918566.0 51 | 1986,1981,951194.0 52 | 1987,1982,944614.0 53 | 1983,1977,698030.0 54 | 1984,1978,823542.0 55 | 1985,1979,958764.0 56 | 1986,1980,964134.0 57 | 1987,1981,1002194.0 58 | 1984,1977,719282.0 59 | 1985,1978,848360.0 60 | 1986,1979,992532.0 61 | 1987,1980,1002134.0 62 | 1985,1977,735904.0 63 | 1986,1978,871022.0 64 | 1987,1979,1019932.0 65 | 1986,1977,750344.0 66 | 1987,1978,889022.0 67 | 1987,1977,762544.0 68 | -------------------------------------------------------------------------------- /chainladder/utils/data/berqsherm.csv: -------------------------------------------------------------------------------- 1 | LOB,AccidentYear,DevelopmentYear,Paid,Incurred,Reported,Closed 2 | MedMal,1969,1969,125000,2897000,782,33 3 | MedMal,1970,1970,43000,4828000,665,5 4 | MedMal,1971,1971,295000,5455000,928,50 5 | MedMal,1972,1972,50000,8732000,1049,6 6 | MedMal,1973,1973,213000,11228000,1109,21 7 | MedMal,1974,1974,172000,8706000,1054,21 8 | MedMal,1975,1975,210000,12928000,1156,18 9 | MedMal,1976,1976,209000,15791000,1211,15 10 | MedMal,1969,1970,406000,5160000,912,72 11 | MedMal,1970,1971,529000,10707000,1006,49 12 | MedMal,1971,1972,1147000,11941000,1470,141 13 | MedMal,1972,1973,786000,18633000,1629,68 14 | MedMal,1973,1974,833000,19967000,1448,60 15 | MedMal,1974,1975,1587000,33459000,1487,69 16 | MedMal,1975,1976,1565000,48904000,1520,48 17 | MedMal,1969,1971,1443000,10714000,1157,156 18 | MedMal,1970,1972,2016000,16907000,1304,155 19 | MedMal,1971,1973,2479000,20733000,1954,234 20 | MedMal,1972,1974,3810000,32143000,2074,246 21 | MedMal,1973,1975,3599000,50143000,1659,119 22 | MedMal,1974,1976,6267000,63477000,1845,182 23 | MedMal,1969,1972,2986000,15228000,1500,294 24 | MedMal,1970,1973,3641000,22840000,1605,255 25 | MedMal,1971,1974,5071000,30928000,2151,352 26 | MedMal,1972,1975,9771000,57196000,2284,390 27 | MedMal,1973,1976,11292000,73733000,2216,339 28 | MedMal,1969,1973,4467000,16611000,1414,380 29 | MedMal,1970,1974,7523000,26211000,1535,440 30 | MedMal,1971,1975,11399000,42395000,1953,525 31 | MedMal,1972,1976,18518000,61163000,2183,661 32 | MedMal,1969,1974,8179000,20899000,1256,491 33 | MedMal,1970,1975,14295000,31970000,1365,610 34 | MedMal,1971,1976,17707000,48377000,1665,609 35 | MedMal,1969,1975,12638000,22892000,1189,656 36 | MedMal,1970,1976,18983000,32216000,1311,772 37 | MedMal,1969,1976,15815000,23506000,1097,738 38 | Auto,1969,1969,1904,2897000,6553,4079 39 | Auto,1970,1970,2235,4828000,7277,4429 40 | Auto,1971,1971,2441,5455000,8259,4914 41 | Auto,1972,1972,2503,8732000,7858,4497 42 | Auto,1973,1973,2838,11228000,7808,4419 43 | Auto,1974,1974,2405,8706000,6278,3486 44 | Auto,1975,1975,2759,12928000,6446,3516 45 | Auto,1976,1976,2801,15791000,6115,3230 46 | Auto,1969,1970,5398,5160000,7696,6616 47 | Auto,1970,1971,6261,10707000,8537,7230 48 | Auto,1971,1972,7348,11941000,9765,8174 49 | Auto,1972,1973,8173,18633000,9474,7842 50 | Auto,1973,1974,8712,19967000,9376,7665 51 | Auto,1974,1975,7858,33459000,7614,6214 52 | Auto,1975,1976,9182,48904000,7884,6226 53 | Auto,1969,1971,7496,10714000,7770,7192 54 | Auto,1970,1972,8691,16907000,8615,7899 55 | Auto,1971,1973,10662,20733000,9884,9068 56 | Auto,1972,1974,11810,32143000,9615,8747 57 | Auto,1973,1975,12728,50143000,9513,8659 58 | Auto,1974,1976,11771,63477000,7741,6916 59 | Auto,1969,1972,8882,15228000,7799,7494 60 | Auto,1970,1973,10443,22840000,8661,8291 61 | Auto,1971,1974,12655,30928000,9926,9518 62 | Auto,1972,1975,14176,57196000,9664,9254 63 | Auto,1973,1976,15278,73733000,9562,9093 64 | Auto,1969,1973,9712,16611000,7814,7670 65 | Auto,1970,1974,11346,26211000,8675,8494 66 | Auto,1971,1975,13748,42395000,9940,9761 67 | Auto,1972,1976,15383,61163000,9680,9469 68 | Auto,1969,1974,10071,20899000,7819,7749 69 | Auto,1970,1975,11754,31970000,8679,8606 70 | Auto,1971,1976,14235,48377000,9945,9855 71 | Auto,1969,1975,10199,22892000,7820,7792 72 | Auto,1970,1976,12031,32216000,8682,8647 73 | Auto,1969,1976,10256,23506000,7821,7806 74 | -------------------------------------------------------------------------------- /chainladder/utils/data/cc_sample.csv: -------------------------------------------------------------------------------- 1 | ,origin,development,loss,exposure 2 | 0,1993,1993,1058.823529,7000 3 | 1,1994,1994,1333.333333,8000 4 | 2,1995,1995,2000.0,9000 5 | 3,1996,1996,2000.0,10000 6 | 4,1997,1997,2800.0,11000 7 | 5,1993,1994,1905.8823530000002,7000 8 | 6,1994,1995,2400.0,8000 9 | 7,1995,1996,3600.0,9000 10 | 8,1996,1997,3600.0,10000 11 | 9,1993,1995,2541.176471,7000 12 | 10,1994,1996,3200.0,8000 13 | 11,1995,1997,4800.0,9000 14 | 12,1993,1996,3176.4705879999997,7000 15 | 13,1994,1997,4000.0,8000 16 | 14,1993,1997,3600.0,7000 17 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_auto_bi_insurer.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 2000,2000,, 3 | 2000,2001,, 4 | 2000,2002,, 5 | 2000,2003,, 6 | 2000,2004,, 7 | 2000,2005,, 8 | 2000,2006,, 9 | 2000,2007,8673913.04347826,9852941.17647059 10 | 2000,2008,9500000,10000000 11 | 2001,2001,, 12 | 2001,2002,, 13 | 2001,2003,, 14 | 2001,2004,, 15 | 2001,2005,, 16 | 2001,2006,, 17 | 2001,2007,6624000,7922330.09708738 18 | 2001,2008,7200000,8000000 19 | 2002,2002,, 20 | 2002,2003,, 21 | 2002,2004,, 22 | 2002,2005,, 23 | 2002,2006,, 24 | 2002,2007,7037037.03703704,8801818.18181818 25 | 2002,2008,7600000,9400000 26 | 2003,2003,, 27 | 2003,2004,, 28 | 2003,2005,, 29 | 2003,2006,, 30 | 2003,2007,6017142.85714286,14300000 31 | 2003,2008,7800000,15600000 32 | 2004,2004,, 33 | 2004,2005,, 34 | 2004,2006,, 35 | 2004,2007,7840000,14142857.1428571 36 | 2004,2008,11200000,16500000 37 | 2005,2005,, 38 | 2005,2006,, 39 | 2005,2007,5100000,14388888.8888889 40 | 2005,2008,10200000,18500000 41 | 2006,2006,, 42 | 2006,2007,2000000,10241379.3103448 43 | 2006,2008,6000000,16500000 44 | 2007,2007,500000,10150000 45 | 2007,2008,3000000,14000000 46 | 2008,2008,750000,8700000 47 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_auto_freq_sev.csv: -------------------------------------------------------------------------------- 1 | Accident Half-Year,Calendar Half-Year,Closed Claim Counts,Reported Claim Counts,Reported Claims,Reported Severity 2 | 2003-02,2003-02,2547,3556,14235000,4003 3 | 2003-02,2004-01,3262,3314,14960000,4514 4 | 2003-02,2004-02,3287,3301,14921000,4520 5 | 2003-02,2005-01,3291,3299,14911000,4520 6 | 2003-02,2005-02,3292,3295,14926000,4530 7 | 2003-02,2006-01,3292,3294,14864000,4512 8 | 2003-02,2006-02,3292,3293,14860000,4513 9 | 2003-02,2007-01,3292,3293,14854000,4511 10 | 2003-02,2007-02,3292,3293,14850000,4510 11 | 2003-02,2008-01,3292,3292,14847000,4510 12 | 2004-01,2004-01,2791,3492,14548000,4166 13 | 2004-01,2004-02,3217,3262,14674000,4498 14 | 2004-01,2005-01,3240,3250,14643000,4506 15 | 2004-01,2005-02,3242,3247,14626000,4505 16 | 2004-01,2006-01,3243,3247,14621000,4503 17 | 2004-01,2006-02,3243,3245,14610000,4502 18 | 2004-01,2007-01,3243,3245,14610000,4502 19 | 2004-01,2007-02,3243,3244,14611000,4504 20 | 2004-01,2008-01,3242,3243,14617000,4507 21 | 2004-02,2004-02,2099,2980,12129000,4070 22 | 2004-02,2005-01,2677,2712,12576000,4637 23 | 2004-02,2005-02,2695,2704,12541000,4638 24 | 2004-02,2006-01,2697,2702,12531000,4638 25 | 2004-02,2006-02,2697,2700,12523000,4683 26 | 2004-02,2007-01,2698,2700,12523000,4638 27 | 2004-02,2007-02,2698,2699,12510000,4635 28 | 2004-02,2008-01,2698,2699,12502000,4632 29 | 2005-01,2005-01,2370,2896,11980000,4137 30 | 2005-01,2005-02,2735,2768,11921000,4307 31 | 2005-01,2006-01,2751,2761,11882000,4304 32 | 2005-01,2006-02,2754,2758,11862000,4301 33 | 2005-01,2007-01,2755,2758,11854000,4298 34 | 2005-01,2007-02,2755,2758,11844000,4294 35 | 2005-01,2008-01,2756,2757,11841000,4295 36 | 2005-02,2005-02,1966,2814,11283000,4010 37 | 2005-02,2006-01,2609,2650,11843000,4469 38 | 2005-02,2006-02,2630,2640,11805000,4472 39 | 2005-02,2007-01,2634,2639,11789000,4467 40 | 2005-02,2007-02,2634,2638,11772000,4462 41 | 2005-02,2008-01,2634,2636,11770000,4465 42 | 2006-01,2006-01,2261,2808,11947000,4254 43 | 2006-01,2006-02,2671,2712,11856000,4372 44 | 2006-01,2007-01,2694,2704,11820000,4371 45 | 2006-01,2007-02,2696,2701,11772000,4359 46 | 2006-01,2008-01,2697,2700,11760000,4356 47 | 2006-02,2006-02,1949,2799,12503000,4467 48 | 2006-02,2007-01,2637,2675,12762000,4771 49 | 2006-02,2007-02,2659,2670,12706000,4759 50 | 2006-02,2008-01,2662,2668,12697000,4759 51 | 2007-01,2007-01,2059,2578,11662000,4524 52 | 2007-01,2007-02,2496,2533,11523000,4549 53 | 2007-01,2008-01,2520,2529,11492000,4544 54 | 2007-02,2007-02,2083,2791,12647000,4531 55 | 2007-02,2008-01,2732,2778,12854000,4627 56 | 2008-01,2008-01,2533,3139,14071000,4483 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_auto_salsub.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Reported Salvage and Subrogation,Received Salvage and Subrogation,Reported Claims,Paid Claims 2 | 1998,1998,713000,312000,2412000,1991000 3 | 1998,1999,781000,735000,2862000,2858000 4 | 1998,2000,771000,766000,2864000,2861000 5 | 1998,2001,770000,770000,2864000,2864000 6 | 1998,2002,785000,770000,2864000,2864000 7 | 1998,2003,793000,770000,2864000,2864000 8 | 1998,2004,793000,793000,2864000,2864000 9 | 1998,2005,793000,793000,2864000,2864000 10 | 1998,2006,793000,793000,2864000,2864000 11 | 1998,2007,793000,793000,2864000,2864000 12 | 1998,2008,1328000,793000,2864000,2864000 13 | 1999,1999,1369000,704000,4225000,3558000 14 | 1999,2000,1361000,1324000,4677000,4666000 15 | 1999,2001,1360000,1360000,4695000,4694000 16 | 1999,2002,1360000,1360000,4696000,4696000 17 | 1999,2003,1360000,1360000,4697000,4697000 18 | 1999,2004,1360000,1360000,4697000,4697000 19 | 1999,2005,1360000,1360000,4697000,4697000 20 | 1999,2006,1360000,1360000,4697000,4697000 21 | 1999,2007,1360000,1360000,4697000,4697000 22 | 1999,2008,2180000,1360000,4697000,4697000 23 | 2000,2000,2432000,951000,6968000,5718000 24 | 2000,2001,2423000,2356000,7879000,7869000 25 | 2000,2002,2424000,2407000,7896000,7893000 26 | 2000,2003,2421000,2421000,7900000,7900000 27 | 2000,2004,2421000,2421000,7901000,7901000 28 | 2000,2005,2421000,2421000,7902000,7902000 29 | 2000,2006,2421000,2421000,7902000,7902000 30 | 2000,2007,2421000,2421000,7902000,7902000 31 | 2000,2008,3314000,2421000,7902000,7902000 32 | 2001,2001,3674000,2101000,9063000,7967000 33 | 2001,2002,3656000,3591000,10277000,10253000 34 | 2001,2003,3637000,3619000,10314000,10307000 35 | 2001,2004,3635000,3635000,10318000,10317000 36 | 2001,2005,3637000,3635000,10318000,10317000 37 | 2001,2006,3637000,3637000,10318000,10318000 38 | 2001,2007,3637000,3637000,10319000,10319000 39 | 2001,2008,3807000,3637000,10319000,10319000 40 | 2002,2002,4092000,2251000,9982000,8745000 41 | 2002,2003,4085000,4023000,11115000,11076000 42 | 2002,2004,4088000,4082000,11136000,11126000 43 | 2002,2005,4084000,4084000,11138000,11134000 44 | 2002,2006,4085000,4084000,11139000,11136000 45 | 2002,2007,4091000,4084000,11139000,11136000 46 | 2002,2008,3807000,4090000,11137000,11137000 47 | 2003,2003,4092000,2122000,11396000,9658000 48 | 2003,2004,4085000,4264000,12493000,12459000 49 | 2003,2005,4088000,4317000,12508000,12500000 50 | 2003,2006,4084000,4321000,12527000,12526000 51 | 2003,2007,4085000,4360000,12526000,12526000 52 | 2003,2008,4091000,4365000,12527000,12526000 53 | 2004,2004,4805000,2602000,12878000,11088000 54 | 2004,2005,5166000,5100000,14505000,14466000 55 | 2004,2006,5162000,5156000,14540000,14503000 56 | 2004,2007,5163000,5157000,14544000,14505000 57 | 2004,2008,5160000,5160000,14552000,14521000 58 | 2005,2005,5387000,3279000,15181000,13518000 59 | 2005,2006,5735000,5666000,16815000,16775000 60 | 2005,2007,5731000,5731000,16834000,16827000 61 | 2005,2008,5731000,5731000,16837000,16837000 62 | 2006,2006,5337000,3104000,15117000,13322000 63 | 2006,2007,5752000,5493000,16953000,16872000 64 | 2006,2008,5715000,5655000,16945000,16942000 65 | 2007,2007,5590000,2863000,15092000,13191000 66 | 2007,2008,6031000,5957000,16862000,16822000 67 | 2008,2008,5414000,2710000,14727000,12889000 68 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_autoprop.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Reported ALAE,Paid ALAE,Reported Claims,Paid Claims 2 | 1998,1998,684,512,109286,78144 3 | 1998,1999,953,856,111832,105902 4 | 1998,2000,1031,949,110648,107306 5 | 1998,2001,1062,1003,109174,108135 6 | 1998,2002,1080,1049,108849,108307 7 | 1998,2003,1084,1065,108779,108494 8 | 1998,2004,1089,1075,108786,108523 9 | 1998,2005,1092,1080,108646,108628 10 | 1998,2006,1092,1082,108736,108731 11 | 1998,2007,1092,1084,108735,108730 12 | 1998,2008,1092,1084,108732,108730 13 | 1999,1999,625,529,120639,81290 14 | 1999,2000,929,874,119607,114037 15 | 1999,2001,1006,952,116924,115347 16 | 1999,2002,1033,988,116482,115696 17 | 1999,2003,1041,1016,116332,115843 18 | 1999,2004,1046,1024,116230,115930 19 | 1999,2005,1049,1034,116236,115962 20 | 1999,2006,1051,1040,116161,115969 21 | 1999,2007,1051,1042,116160,115969 22 | 1999,2008,1051,1045,116125,116033 23 | 2000,2000,571,471,115422,83563 24 | 2000,2001,771,720,119143,114175 25 | 2000,2002,821,787,118641,116044 26 | 2000,2003,844,821,117008,116458 27 | 2000,2004,858,846,116782,116620 28 | 2000,2005,861,855,116919,116857 29 | 2000,2006,862,857,116860,116810 30 | 2000,2007,862,860,116825,116807 31 | 2000,2008,862,861,116472,116807 32 | 2001,2001,629,480,129430,91475 33 | 2001,2002,894,802,139925,113761 34 | 2001,2003,943,882,138161,136143 35 | 2001,2004,982,836,137395,136552 36 | 2001,2005,997,975,137269,136818 37 | 2001,2006,1002,987,137033,136838 38 | 2001,2007,1003,995,136998,136960 39 | 2001,2008,1007,998,137056,136995 40 | 2002,2002,618,451,134190,92349 41 | 2002,2003,872,793,143852,138461 42 | 2002,2004,952,887,143093,140904 43 | 2002,2005,1005,956,142360,141323 44 | 2002,2006,1033,1004,142004,141380 45 | 2002,2007,1093,1067,141715,141452 46 | 2002,2008,1110,1098,141627,141461 47 | 2003,2003,757,572,152678,111655 48 | 2003,2004,948,874,166131,158092 49 | 2003,2005,1035,974,166015,161823 50 | 2003,2006,1092,1041,165579,162556 51 | 2003,2007,1095,1069,165229,162802 52 | 2003,2008,1143,1085,163508,163257 53 | 2004,2004,743,557,144595,106032 54 | 2004,2005,915,840,154830,149157 55 | 2004,2006,976,921,154295,151729 56 | 2004,2007,1001,960,154228,152229 57 | 2004,2008,1032,989,153750,152613 58 | 2005,2005,789,563,137791,98270 59 | 2005,2006,948,882,154230,149504 60 | 2005,2007,1001,941,154307,152895 61 | 2005,2008,1032,987,153981,153154 62 | 2006,2006,988,636,159818,107131 63 | 2006,2007,1140,1064,178399,171332 64 | 2006,2008,1198,1132,179384,175602 65 | 2007,2007,1373,774,162205,114337 66 | 2007,2008,1596,1454,178425,171505 67 | 2008,2008,1556,952,176030,124470 68 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_berq_sher_auto.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Closed Claim Counts,Reported Claim Counts,Disposal Rate 2 | 1969,1969,1904,4079,6553,0.522 3 | 1969,1970,5398,6616,7696,0.846 4 | 1969,1971,7496,7192,7770,0.92 5 | 1969,1972,8882,7494,7799,0.958 6 | 1969,1973,9712,7670,7814,0.981 7 | 1969,1974,10071,7749,7819,0.991 8 | 1969,1975,10199,7792,7820,0.996 9 | 1969,1976,10256,7806,7821,0.998 10 | 1970,1970,2235,4429,7277,0.51 11 | 1970,1971,6261,7230,8537,0.833 12 | 1970,1972,8691,7899,8615,0.91 13 | 1970,1973,10443,8291,8661,0.955 14 | 1970,1974,11346,8494,8675,0.978 15 | 1970,1975,11754,8606,8679,0.991 16 | 1970,1976,12031,8647,8682,0.996 17 | 1971,1971,2441,4914,8259,0.494 18 | 1971,1972,7348,8174,9765,0.822 19 | 1971,1973,10662,9068,9884,0.912 20 | 1971,1974,12655,9518,9926,0.957 21 | 1971,1975,13748,9761,9940,0.981 22 | 1971,1976,14235,9855,9945,0.991 23 | 1972,1972,2503,4497,7858,0.464 24 | 1972,1973,8173,7842,9474,0.809 25 | 1972,1974,11810,8747,9615,0.903 26 | 1972,1975,14176,9254,9664,0.955 27 | 1972,1976,15383,9469,9680,0.977 28 | 1973,1973,2838,4419,7808,0.461 29 | 1973,1974,8712,7665,9376,0.799 30 | 1973,1975,12728,8659,9513,0.903 31 | 1973,1976,15278,9093,9562,0.948 32 | 1974,1974,2405,3486,6278,0.447 33 | 1974,1975,7858,6214,7614,0.796 34 | 1974,1976,11771,6916,7741,0.886 35 | 1975,1975,2759,3516,6446,0.437 36 | 1975,1976,9182,6226,7884,0.773 37 | 1976,1976,2801,3230,6115,0.433 38 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_gl_insurer.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Closed Claim Counts,Reported Claim Counts,Disposal Rate,Paid Claims 2 | 2001,2001,195,1299,0.223,1119962 3 | 2001,2002,375,1077,0.43,4373268 4 | 2001,2003,510,1057,0.584,8398345 5 | 2001,2004,625,965,0.716,13490793 6 | 2001,2005,702,930,0.804,17372233 7 | 2001,2006,752,917,0.862,22052662 8 | 2001,2007,780,864,0.894,27359691 9 | 2001,2008,796,870,0.912,29901361 10 | 2002,2002,199,847,0.277,1411957 11 | 2002,2003,349,945,0.485,6287005 12 | 2002,2004,445,864,0.618,11443820 13 | 2002,2005,508,787,0.706,15520552 14 | 2002,2006,563,784,0.782,21295572 15 | 2002,2007,594,743,0.826,28410418 16 | 2002,2008,626,731,0.87,32468911 17 | 2003,2003,106,800,0.169,984748 18 | 2003,2004,294,831,0.47,6128957 19 | 2003,2005,383,762,0.612,10470758 20 | 2003,2006,453,704,0.724,14604684 21 | 2003,2007,499,669,0.797,21936647 22 | 2003,2008,542,636,0.866,23942499 23 | 2004,2004,126,823,0.2,1158659 24 | 2004,2005,281,862,0.447,5811172 25 | 2004,2006,377,797,0.599,10497504 26 | 2004,2007,445,728,0.707,15087416 27 | 2004,2008,494,684,0.785,18242570 28 | 2005,2005,114,828,0.194,1198767 29 | 2005,2006,249,850,0.423,5103837 30 | 2005,2007,315,765,0.536,9042134 31 | 2005,2008,403,687,0.685,15443929 32 | 2006,2006,114,824,0.206,1220778 33 | 2006,2007,229,809,0.414,4594746 34 | 2006,2008,300,734,0.543,8983864 35 | 2007,2007,79,604,0.18,796774 36 | 2007,2008,188,620,0.429,4233641 37 | 2008,2008,127,812,0.209,1445365 38 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_med_mal.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Reported Claims,Paid Claims,Case Outstanding,Open Claim Counts 2 | 1969,1969,2897000,125000,2772000,749 3 | 1969,1970,5160000,406000,4754000,840 4 | 1969,1971,10714000,1443000,9271000,1001 5 | 1969,1972,15228000,2986000,12242000,1206 6 | 1969,1973,16611000,4467000,12144000,1034 7 | 1969,1974,20899000,8179000,12720000,765 8 | 1969,1975,22892000,12638000,10254000,533 9 | 1969,1976,23506000,15815000,7691000,359 10 | 1970,1970,4828000,43000,4785000,660 11 | 1970,1971,10707000,529000,10178000,957 12 | 1970,1972,16907000,2016000,14891000,1149 13 | 1970,1973,22840000,3641000,19199000,1350 14 | 1970,1974,26211000,7523000,18688000,1095 15 | 1970,1975,31970000,14295000,17675000,755 16 | 1970,1976,32216000,18983000,13233000,539 17 | 1971,1971,5455000,295000,5160000,878 18 | 1971,1972,11941000,1147000,10794000,1329 19 | 1971,1973,20733000,2479000,18254000,1720 20 | 1971,1974,30928000,5071000,25857000,1799 21 | 1971,1975,42395000,11399000,30996000,1428 22 | 1971,1976,48377000,17707000,30670000,1056 23 | 1972,1972,8732000,50000,8682000,1043 24 | 1972,1973,18633000,786000,17847000,1561 25 | 1972,1974,32143000,3810000,28333000,1828 26 | 1972,1975,57196000,9771000,47425000,1894 27 | 1972,1976,61163000,18518000,42645000,1522 28 | 1973,1973,11228000,213000,11015000,1088 29 | 1973,1974,19967000,833000,19134000,1388 30 | 1973,1975,50143000,3599000,46544000,1540 31 | 1973,1976,73733000,11292000,62441000,1877 32 | 1974,1974,8706000,172000,8534000,1033 33 | 1974,1975,33459000,1587000,31872000,1418 34 | 1974,1976,63477000,6267000,57210000,1663 35 | 1975,1975,12928000,210000,12718000,1138 36 | 1975,1976,48904000,1565000,47339000,1472 37 | 1976,1976,15791000,209000,15582000,1196 38 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_qs.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Gross Reported Claims,Net Reported Claims,Net to Gross 2 | 2005,2005,35839,25087,0.7 3 | 2005,2006,42290,29603,0.7 4 | 2005,2007,47365,33155,0.7 5 | 2005,2008,49733,34813,0.7 6 | 2006,2006,37452,26216,0.7 7 | 2006,2007,44568,31197,0.7 8 | 2006,2008,49024,34317,0.7 9 | 2007,2007,39324,33426,0.85 10 | 2007,2008,46009,39108,0.85 11 | 2008,2008,41212,37091,0.9 12 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_us_auto_chg_prod_mix.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1999,1999,470000,1011000 3 | 1999,2000,865000,1254000 4 | 1999,2001,1124000,1377000 5 | 1999,2002,1300000,1454000 6 | 1999,2003,1400000,1477000 7 | 1999,2004,1446000,1493000 8 | 1999,2005,1469000,1500000 9 | 1999,2006,1477000,1500000 10 | 1999,2007,1492000,1500000 11 | 1999,2008,1500000,1500000 12 | 2000,2000,493500,1061550 13 | 2000,2001,908250,1316700 14 | 2000,2002,1180200,1445850 15 | 2000,2003,1365000,1526700 16 | 2000,2004,1470000,1550850 17 | 2000,2005,1518300,1567650 18 | 2000,2006,1542450,1575000 19 | 2000,2007,1550850,1575000 20 | 2000,2008,1566600,1575000 21 | 2001,2001,518175,1114628 22 | 2001,2002,953663,1382535 23 | 2001,2003,1239210,1518143 24 | 2001,2004,1433250,1603035 25 | 2001,2005,1543500,1628393 26 | 2001,2006,1594215,1646033 27 | 2001,2007,1619573,1653750 28 | 2001,2008,1628393,1653750 29 | 2002,2002,544084,1170359 30 | 2002,2003,1001346,1451662 31 | 2002,2004,1301171,1594050 32 | 2002,2005,1504913,1683187 33 | 2002,2006,1620675,1709812 34 | 2002,2007,1673926,1728334 35 | 2002,2008,1700551,1736438 36 | 2003,2003,571288,1228877 37 | 2003,2004,1051413,1524245 38 | 2003,2005,1366229,1673752 39 | 2003,2006,1580158,1767346 40 | 2003,2007,1701709,1795303 41 | 2003,2008,1757622,1814751 42 | 2004,2004,599852,1290321 43 | 2004,2005,1103984,1600457 44 | 2004,2006,1434540,1757440 45 | 2004,2007,1659166,1855713 46 | 2004,2008,1786794,1885068 47 | 2005,2005,686001,1505438 48 | 2005,2006,1276601,1879580 49 | 2005,2007,1677289,2072490 50 | 2005,2008,1951435,2193545 51 | 2006,2006,793305,1776491 52 | 2006,2007,1493074,2232389 53 | 2006,2008,1983482,2471446 54 | 2007,2007,927874,2119832 55 | 2007,2008,1766164,2680487 56 | 2008,2008,1097644,2556695 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_us_auto_incr_claim.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1999,1999,294000,539000 3 | 1999,2000,497000,630000 4 | 1999,2001,588000,665000 5 | 1999,2002,644000,686000 6 | 1999,2003,672000,693000 7 | 1999,2004,686000,693000 8 | 1999,2005,693000,700000 9 | 1999,2006,693000,700000 10 | 1999,2007,700000,700000 11 | 1999,2008,700000,700000 12 | 2000,2000,308700,565950 13 | 2000,2001,521850,611500 14 | 2000,2002,617400,698250 15 | 2000,2003,676200,720300 16 | 2000,2004,705600,727650 17 | 2000,2005,720300,727650 18 | 2000,2006,727650,735000 19 | 2000,2007,727650,735000 20 | 2000,2008,735000,735000 21 | 2001,2001,324135,594248 22 | 2001,2002,547943,694575 23 | 2001,2003,648270,733163 24 | 2001,2004,710010,756315 25 | 2001,2005,740880,764033 26 | 2001,2006,756315,764033 27 | 2001,2007,764033,771750 28 | 2001,2008,764033,771750 29 | 2002,2002,340342,623960 30 | 2002,2003,575340,729304 31 | 2002,2004,680684,769821 32 | 2002,2005,745511,794131 33 | 2002,2006,777924,802234 34 | 2002,2007,794131,802234 35 | 2002,2008,802234,810338 36 | 2003,2003,357359,655158 37 | 2003,2004,604107,765769 38 | 2003,2005,714718,808312 39 | 2003,2006,782786,833837 40 | 2003,2007,816820,842346 41 | 2003,2008,833837,842346 42 | 2004,2004,428831,786189 43 | 2004,2005,724928,918923 44 | 2004,2006,857661,969974 45 | 2004,2007,939343,1000605 46 | 2004,2008,980184,1010815 47 | 2005,2005,478414,877093 48 | 2005,2006,808748,1025173 49 | 2005,2007,956828,1082127 50 | 2005,2008,1047955,1116300 51 | 2006,2006,531884,975121 52 | 2006,2007,899137,1139751 53 | 2006,2008,1063768,1203071 54 | 2007,2007,589505,1080759 55 | 2007,2008,996544,1263224 56 | 2008,2008,651558,1194523 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_us_auto_steady_state.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1999,1999,470000,1011000 3 | 1999,2000,865000,1254000 4 | 1999,2001,1124000,1377000 5 | 1999,2002,1300000,1454000 6 | 1999,2003,1400000,1477000 7 | 1999,2004,1446000,1493000 8 | 1999,2005,1469000,1500000 9 | 1999,2006,1477000,1500000 10 | 1999,2007,1492000,1500000 11 | 1999,2008,1500000,1500000 12 | 2000,2000,493500,1061550 13 | 2000,2001,908250,1316700 14 | 2000,2002,1180200,1445850 15 | 2000,2003,1365000,1526700 16 | 2000,2004,1470000,1550850 17 | 2000,2005,1518300,1567650 18 | 2000,2006,1542450,1575000 19 | 2000,2007,1550850,1575000 20 | 2000,2008,1566600,1575000 21 | 2001,2001,518175,1114628 22 | 2001,2002,953663,1382535 23 | 2001,2003,1239210,1518143 24 | 2001,2004,1433250,1603035 25 | 2001,2005,1543500,1628393 26 | 2001,2006,1594215,1646033 27 | 2001,2007,1619573,1653750 28 | 2001,2008,1628393,1653750 29 | 2002,2002,544084,1170359 30 | 2002,2003,1001346,1451662 31 | 2002,2004,1301171,1594050 32 | 2002,2005,1504913,1683187 33 | 2002,2006,1620675,1709812 34 | 2002,2007,1673926,1728334 35 | 2002,2008,1700551,1736438 36 | 2003,2003,571288,1228877 37 | 2003,2004,1051413,1524245 38 | 2003,2005,1366229,1673752 39 | 2003,2006,1580158,1767346 40 | 2003,2007,1701709,1795303 41 | 2003,2008,1757622,1814751 42 | 2004,2004,599852,1290321 43 | 2004,2005,1103984,1600457 44 | 2004,2006,1434540,1757440 45 | 2004,2007,1659166,1855713 46 | 2004,2008,1786794,1885068 47 | 2005,2005,629845,1354837 48 | 2005,2006,1159183,1680480 49 | 2005,2007,1506268,1845312 50 | 2005,2008,1742124,1948499 51 | 2006,2006,661337,1422579 52 | 2006,2007,1217142,1764504 53 | 2006,2008,1581581,1937577 54 | 2007,2007,694404,1493707 55 | 2008,2008,1277999,1852729 56 | 2008,2008,729124,1568393 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_us_industry_auto.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1998,1998,18539254,37017487 3 | 1998,1999,33231039,43169009 4 | 1998,2000,40062008,45568919 5 | 1998,2001,43892039,46784558 6 | 1998,2002,45896535,47337318 7 | 1998,2003,46765422,47533264 8 | 1998,2004,47221322,47634419 9 | 1998,2005,47446877,47689655 10 | 1998,2006,47555456,47724678 11 | 1998,2007,47644187,47742304 12 | 1999,1999,20410193,38954484 13 | 1999,2000,36090684,46045718 14 | 1999,2001,43259402,48882924 15 | 1999,2002,47159241,50219672 16 | 1999,2003,49208532,50729292 17 | 1999,2004,50162043,50926779 18 | 1999,2005,50625757,51069285 19 | 1999,2006,50878808,51163540 20 | 1999,2007,51000534,51185767 21 | 2000,2000,22120843,41155776 22 | 2000,2001,38976014,49371478 23 | 2000,2002,46389282,52358476 24 | 2000,2003,50562385,53780322 25 | 2000,2004,52735280,54303086 26 | 2000,2005,53740101,54582950 27 | 2000,2006,54284334,54742188 28 | 2000,2007,54533225,54837929 29 | 2001,2001,22992259,42394069 30 | 2001,2002,40096198,50584112 31 | 2001,2003,47767835,53704296 32 | 2001,2004,52093916,55150118 33 | 2001,2005,54363436,55895583 34 | 2001,2006,55378801,56156727 35 | 2001,2007,55878421,56299562 36 | 2002,2002,24092782,44755243 37 | 2002,2003,41795313,52971643 38 | 2002,2004,49903803,56102312 39 | 2002,2005,54352884,57703851 40 | 2002,2006,56754376,58363564 41 | 2002,2007,57807215,58592712 42 | 2003,2003,24084451,45163102 43 | 2003,2004,41399612,52497731 44 | 2003,2005,49070332,55468551 45 | 2003,2006,53584201,57015411 46 | 2003,2007,55930654,57565344 47 | 2004,2004,24369770,45417309 48 | 2004,2005,41489863,52640322 49 | 2004,2006,49236678,55553673 50 | 2004,2007,53774672,56976657 51 | 2005,2005,25100697,46360869 52 | 2005,2006,42702229,53790061 53 | 2005,2007,50644994,56786410 54 | 2006,2006,25608776,46582684 55 | 2006,2007,43606497,54641339 56 | 2007,2007,27229969,48853563 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_us_industry_auto_case.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Case Outstanding,Incremental Paid Claims 2 | 1998,1998,18478233,18539254 3 | 1998,1999,9937970,14691785 4 | 1998,2000,5506911,6830969 5 | 1998,2001,2892519,3830031 6 | 1998,2002,1440783,2004496 7 | 1998,2003,767842,868887 8 | 1998,2004,413097,455900 9 | 1998,2005,242778,225555 10 | 1998,2006,169222,108579 11 | 1998,2007,98117,88731 12 | 1999,1999,18544291,20410193 13 | 1999,2000,9955034,15680491 14 | 1999,2001,5623522,7168718 15 | 1999,2002,3060431,3899839 16 | 1999,2003,1520760,2049291 17 | 1999,2004,764736,953511 18 | 1999,2005,443528,463714 19 | 1999,2006,284732,253051 20 | 1999,2007,185233,121726 21 | 2000,2000,19034933,22120843 22 | 2000,2001,10395464,16855171 23 | 2000,2002,5969194,7413268 24 | 2000,2003,3217937,4173103 25 | 2000,2004,1567806,2172895 26 | 2000,2005,842849,1004821 27 | 2000,2006,457854,544233 28 | 2000,2007,304704,248891 29 | 2001,2001,19401810,22992259 30 | 2001,2002,10487914,17103939 31 | 2001,2003,5936461,7671637 32 | 2001,2004,3056202,4326081 33 | 2001,2005,1532147,2269520 34 | 2001,2006,777926,1015365 35 | 2001,2007,421141,499620 36 | 2002,2002,20662461,24092782 37 | 2002,2003,11176330,17702531 38 | 2002,2004,6198509,8108490 39 | 2002,2005,3350967,4449081 40 | 2002,2006,1609188,2401492 41 | 2002,2007,785497,1052839 42 | 2003,2003,21078651,24084451 43 | 2003,2004,11098119,17315161 44 | 2003,2005,6398219,7670720 45 | 2003,2006,3431210,4513869 46 | 2003,2007,1634690,2346453 47 | 2004,2004,21047539,24369770 48 | 2004,2005,11150459,17120093 49 | 2004,2006,6316995,7746815 50 | 2004,2007,3201985,4537994 51 | 2005,2005,21260172,25100697 52 | 2005,2006,11087832,17601532 53 | 2005,2007,6141416,7942765 54 | 2006,2006,20973908,25608776 55 | 2006,2007,11034842,17997721 56 | 2007,2007,21623594,27229969 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_uspp_auto_increasing_case.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1999,1999,294000,539000 3 | 1999,2000,497000,630000 4 | 1999,2001,588000,665000 5 | 1999,2002,644000,686000 6 | 1999,2003,672000,693000 7 | 1999,2004,686000,693000 8 | 1999,2005,693000,700000 9 | 1999,2006,693000,700000 10 | 1999,2007,700000,700000 11 | 1999,2008,700000,700000 12 | 2000,2000,308700,565950 13 | 2000,2001,521850,661500 14 | 2000,2002,617400,698250 15 | 2000,2003,676200,720300 16 | 2000,2004,705600,727650 17 | 2000,2005,720300,727650 18 | 2000,2006,727650,735000 19 | 2000,2007,727650,735000 20 | 2000,2008,735000,735000 21 | 2001,2001,324135,594248 22 | 2001,2002,547943,694575 23 | 2001,2003,648270,733163 24 | 2001,2004,710010,756315 25 | 2001,2005,740880,764033 26 | 2001,2006,756315,764033 27 | 2001,2007,764033,771750 28 | 2001,2008,764033,771750 29 | 2002,2002,340342,623960 30 | 2002,2003,575340,729304 31 | 2002,2004,680684,769821 32 | 2002,2005,745511,794131 33 | 2002,2006,777924,802234 34 | 2002,2007,794131,802234 35 | 2002,2008,802234,810338 36 | 2003,2003,357359,655158 37 | 2003,2004,604107,765769 38 | 2003,2005,714718,808312 39 | 2003,2006,782786,833837 40 | 2003,2007,816820,842346 41 | 2003,2008,833837,842346 42 | 2004,2004,375227,687916 43 | 2004,2005,634312,804057 44 | 2004,2006,750454,848727 45 | 2004,2007,821925,878745 46 | 2004,2008,857661,884463 47 | 2005,2005,393988,722312 48 | 2005,2006,666028,844260 49 | 2005,2007,787976,897355 50 | 2005,2008,863022,933377 51 | 2006,2006,413688,758427 52 | 2006,2007,699329,897702 53 | 2006,2008,827375,962808 54 | 2007,2007,434372,818067 55 | 2007,2008,734295,979922 56 | 2008,2008,456090,931185 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_uspp_auto_increasing_claim.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1999,1999,294000,539000 3 | 1999,2000,497000,630000 4 | 1999,2001,588000,665000 5 | 1999,2002,644000,686000 6 | 1999,2003,672000,698000 7 | 1999,2004,686000,693000 8 | 1999,2005,693000,700000 9 | 1999,2006,693000,700000 10 | 1999,2007,700000,700000 11 | 1999,2008,700000,700000 12 | 2000,2000,308700,565950 13 | 2000,2001,521850,661500 14 | 2000,2002,617400,698250 15 | 2000,2003,676200,720300 16 | 2000,2004,705600,727650 17 | 2000,2005,720300,727650 18 | 2000,2006,727650,735000 19 | 2000,2007,727650,735000 20 | 2000,2008,735000,735000 21 | 2001,2001,324135,594248 22 | 2001,2002,547943,694575 23 | 2001,2003,648270,733163 24 | 2001,2004,710010,756315 25 | 2001,2005,740880,764033 26 | 2001,2006,756315,764033 27 | 2001,2007,764033,771750 28 | 2001,2008,764033,771750 29 | 2002,2002,340342,623960 30 | 2002,2003,575340,729304 31 | 2002,2004,680684,769821 32 | 2002,2005,745511,794131 33 | 2002,2006,777924,802234 34 | 2002,2007,794131,802234 35 | 2002,2008,802234,810338 36 | 2003,2003,357359,655158 37 | 2003,2004,604107,765769 38 | 2003,2005,714718,808312 39 | 2003,2006,782786,833837 40 | 2003,2007,816820,842346 41 | 2003,2008,833837,842346 42 | 2004,2004,428831,786189 43 | 2004,2005,724928,918923 44 | 2004,2006,857661,969974 45 | 2004,2007,939343,1000605 46 | 2004,2008,980184,1010815 47 | 2005,2005,478414,877093 48 | 2005,2006,808748,1025173 49 | 2005,2007,956828,1082127 50 | 2005,2008,1047955,1116300 51 | 2006,2006,531884,975121 52 | 2006,2007,899137,1139751 53 | 2006,2008,1063768,1203071 54 | 2007,2007,589505,1080759 55 | 2007,2008,996544,1263224 56 | 2008,2008,651558,1194523 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_uspp_auto_steady_state.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1999,1999,294000,539000 3 | 1999,2000,497000,630000 4 | 1999,2001,588000,665000 5 | 1999,2002,644000,686000 6 | 1999,2003,672000,693000 7 | 1999,2004,686000,693000 8 | 1999,2005,693000,700000 9 | 1999,2006,693000,700000 10 | 1999,2007,700000,700000 11 | 1999,2008,700000,700000 12 | 2000,2000,308700,565950 13 | 2000,2001,521850,662600 14 | 2000,2002,617400,698250 15 | 2000,2003,676200,720300 16 | 2000,2004,705600,727650 17 | 2000,2005,720300,727650 18 | 2000,2006,727650,735000 19 | 2000,2007,727650,735000 20 | 2000,2008,735000,735000 21 | 2001,2001,324135,594248 22 | 2001,2002,547943,694575 23 | 2001,2003,648270,733163 24 | 2001,2004,710000,756315 25 | 2001,2005,740880,764033 26 | 2001,2006,756315,764033 27 | 2001,2007,764033,771750 28 | 2001,2008,764033,771750 29 | 2002,2002,340342,623960 30 | 2002,2003,575340,729304 31 | 2002,2004,680864,769821 32 | 2002,2005,745511,794131 33 | 2002,2006,777924,802234 34 | 2002,2007,794131,802234 35 | 2002,2008,802234,810338 36 | 2003,2003,357359,655158 37 | 2003,2004,604107,765769 38 | 2003,2005,714718,808312 39 | 2003,2006,782786,833837 40 | 2003,2007,816820,842346 41 | 2003,2008,833837,842346 42 | 2004,2004,375227,687916 43 | 2004,2005,634312,804057 44 | 2004,2006,750454,848727 45 | 2004,2007,821925,875529 46 | 2004,2008,857661,884463 47 | 2005,2005,393988,722312 48 | 2005,2006,666028,844260 49 | 2005,2007,787976,891164 50 | 2005,2008,863022,919306 51 | 2006,2006,413688,758427 52 | 2006,2007,699329,886473 53 | 2006,2008,827375,935722 54 | 2007,2007,434372,796348 55 | 2007,2008,734295,930797 56 | 2008,2008,456090,836166 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_uspp_increasing_claim_case.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1999,1999,294000,539000 3 | 1999,2000,497000,630000 4 | 1999,2001,588000,665000 5 | 1999,2002,644000,686000 6 | 1999,2003,672000,693000 7 | 1999,2004,686000,693000 8 | 1999,2005,693000,700000 9 | 1999,2006,693000,700000 10 | 1999,2007,700000,700000 11 | 1999,2008,700000,565950 12 | 2000,2000,308700,661500 13 | 2000,2001,521850,698250 14 | 2000,2002,617400,720300 15 | 2000,2003,676200,727650 16 | 2000,2004,705600,727650 17 | 2000,2005,720300,735000 18 | 2000,2006,727650,735000 19 | 2000,2007,727560,735000 20 | 2000,2008,735000,735000 21 | 2001,2001,324135,594248 22 | 2001,2002,547943,694575 23 | 2001,2003,648270,733163 24 | 2001,2004,710010,756315 25 | 2001,2005,740880,764033 26 | 2001,2006,756315,764033 27 | 2001,2007,764033,771750 28 | 2001,2008,764033,771750 29 | 2002,2002,340342,623960 30 | 2002,2003,575340,729304 31 | 2002,2004,680684,769821 32 | 2002,2005,745511,794131 33 | 2002,2006,777924,802234 34 | 2002,2007,794131,802234 35 | 2002,2008,802234,810338 36 | 2003,2003,357359,655158 37 | 2003,2004,604107,765769 38 | 2003,2005,714718,808312 39 | 2003,2006,782786,833837 40 | 2003,2007,816820,842346 41 | 2003,2008,833837,842346 42 | 2004,2004,428831,786189 43 | 2004,2005,724928,918923 44 | 2004,2006,857661,969974 45 | 2004,2007,939343,1004280 46 | 2004,2008,980184,1010815 47 | 2005,2005,478414,877093 48 | 2005,2006,808748,1025173 49 | 2005,2007,956828,1089645 50 | 2005,2008,1047955,1133386 51 | 2006,2006,531884,975121 52 | 2006,2007,899137,1154188 53 | 2006,2008,1063768,1237897 54 | 2007,2007,589505,1110234 55 | 2008,2008,996544,1329895 56 | 2008,2008,651558,1330264 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_wc_self_insurer.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Closed Claim Counts,Reported Claim Counts,Paid Claims,Paid Severities,Reported Claims,Reported Severities 2 | 2001,2001,789,1235,1318000,1670,3200000,2591 3 | 2001,2002,1196,1321,2842000,2377,4300000,3255 4 | 2001,2003,1255,1342,3750000,2989,4900000,3651 5 | 2001,2004,1310,1349,4300000,3283,5200000,3855 6 | 2001,2005,1324,1350,4650000,3511,5300000,3926 7 | 2001,2006,1327,1350,4850000,3655,5400000,4000 8 | 2001,2007,1332,1350,5050000,3790,5550000,4111 9 | 2001,2008,1343,1350,5200000,3871,5650000,4185 10 | 2002,2002,978,1555,1780000,1820,4300000,2765 11 | 2002,2003,1506,1660,3817000,2535,5900000,3554 12 | 2002,2004,1609,1685,5016000,3117,6600000,3917 13 | 2002,2005,1629,1695,5750000,3530,6950000,4100 14 | 2002,2006,1669,1700,6100000,3654,7200000,4235 15 | 2002,2007,1676,1700,6300000,3759,7400000,4353 16 | 2002,2008,1683,1700,6555000,3895,7500000,4412 17 | 2003,2003,1070,1628,1890000,1767,4800000,2948 18 | 2003,2004,1557,1740,4184000,2687,6600000,3793 19 | 2003,2005,1665,1762,5500000,3303,7400000,4200 20 | 2003,2006,1721,1771,6300000,3660,7800000,4404 21 | 2003,2007,1738,1775,6800000,3913,8100000,4563 22 | 2003,2008,1748,1775,7100000,4061,8300000,4676 23 | 2004,2004,1029,1600,1900000,1847,4900000,3063 24 | 2004,2005,1525,1714,4100000,2688,6700000,3909 25 | 2004,2006,1618,1740,5560000,3436,7700000,4425 26 | 2004,2007,1688,1747,6430000,3810,8150000,4665 27 | 2004,2008,1717,1750,6950000,4048,8600000,4914 28 | 2005,2005,974,1510,1960000,2012,5200000,3444 29 | 2005,2006,1459,1612,4290000,2941,7100000,4404 30 | 2005,2007,1532,1639,5688000,3712,7900000,4821 31 | 2005,2008,1597,1647,6570000,4113,8350000,5071 32 | 2006,2006,1746,2750,4030000,2308,10100000,3673 33 | 2006,2007,2632,2941,8650000,3286,13800000,4692 34 | 2006,2008,2761,2985,11400000,4129,15500000,5193 35 | 2007,2007,1683,2640,4200000,3496,10500000,3962 36 | 2007,2008,2572,2842,9043000,3516,14400000,5067 37 | 2008,2008,1560,2438,4170000,2673,10300000,4225 38 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_xol.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Gross Reported Claims,Net Reported Claims,Ceded Reported Claims 2 | 2005,2005,12199,11752,447 3 | 2005,2006,15615,14076,1539 4 | 2005,2007,18425,16502,1924 5 | 2005,2008,20268,18056,2212 6 | 2006,2006,12992,12992,0 7 | 2006,2007,16890,16890,0 8 | 2006,2008,20267,20267,0 9 | 2007,2007,13901,13644,257 10 | 2007,2008,17655,17303,352 11 | 2008,2008,14735,14735,0 12 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_xyz_auto_bi.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Paid Claims,Reported Claims 2 | 1998,1998,, 3 | 1998,1999,, 4 | 1998,2000,6309,11171 5 | 1998,2001,8521,12380 6 | 1998,2002,10082,13216 7 | 1998,2003,11620,14067 8 | 1998,2004,13242,14688 9 | 1998,2005,14419,16366 10 | 1998,2006,15311,16163 11 | 1998,2007,15764,15835 12 | 1998,2008,15822,15822 13 | 1999,1999,, 14 | 1999,2000,4666,13255 15 | 1999,2001,9861,16405 16 | 1999,2002,13971,19639 17 | 1999,2003,18127,22473 18 | 1999,2004,22032,23764 19 | 1999,2005,23511,25094 20 | 1999,2006,24146,24795 21 | 1999,2007,24592,25071 22 | 1999,2008,24817,25107 23 | 2000,2000,1302,15676 24 | 2000,2001,6513,18749 25 | 2000,2002,12139,21900 26 | 2000,2003,17828,27144 27 | 2000,2004,24030,29488 28 | 2000,2005,28853,34458 29 | 2000,2006,33222,36949 30 | 2000,2007,35902,37505 31 | 2000,2008,36782,37246 32 | 2001,2001,1539,11827 33 | 2001,2002,5952,16004 34 | 2001,2003,12319,21022 35 | 2001,2004,18609,26578 36 | 2001,2005,24387,34205 37 | 2001,2006,31090,37136 38 | 2001,2007,37070,38541 39 | 2001,2008,38519,38798 40 | 2002,2002,2318,12811 41 | 2002,2003,7932,20370 42 | 2002,2004,13822,26656 43 | 2002,2005,22095,37667 44 | 2002,2006,31945,44414 45 | 2002,2007,40629,48701 46 | 2002,2008,44437,48169 47 | 2003,2003,1743,9651 48 | 2003,2004,6240,16995 49 | 2003,2005,12683,30354 50 | 2003,2006,22892,40594 51 | 2003,2007,34505,44231 52 | 2003,2008,39320,44373 53 | 2004,2004,2221,16995 54 | 2004,2005,9898,40180 55 | 2004,2006,25950,58866 56 | 2004,2007,43439,71707 57 | 2004,2008,52811,70288 58 | 2005,2005,3043,28674 59 | 2005,2006,12219,47432 60 | 2005,2007,27073,70340 61 | 2005,2008,40026,70655 62 | 2006,2006,3531,27066 63 | 2006,2007,11778,46783 64 | 2006,2008,22819,48804 65 | 2007,2007,3529,19477 66 | 2007,2008,11865,31732 67 | 2008,2008,3409,18632 68 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_xyz_case.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Case Outstanding,Incremental Paid Claims,Incremental Paid to Previous Case,Case to Previous Case 2 | 1998,1998,,,, 3 | 1998,1999,,,, 4 | 1998,2000,4861,6309,, 5 | 1998,2001,3859,2212,0.455,0.794 6 | 1998,2002,3134,1561,0.405,0.812 7 | 1998,2003,2447,1537,0.491,0.781 8 | 1998,2004,1446,1622,0.663,0.591 9 | 1998,2005,1947,1177,0.814,1.346 10 | 1998,2006,853,892,0.458,0.438 11 | 1998,2007,71,453,0.532,0.084 12 | 1998,2008,0,58,0.816,0 13 | 1999,1999,,,, 14 | 1999,2000,8589,4666,, 15 | 1999,2001,6544,5195,0.605,0.762 16 | 1999,2002,5668,4110,0.628,0.866 17 | 1999,2003,4347,4156,0.733,0.767 18 | 1999,2004,1732,3906,0.899,0.398 19 | 1999,2005,1583,1478,0.854,0.914 20 | 1999,2006,649,635,0.401,0.41 21 | 1999,2007,479,446,0.688,0.739 22 | 1999,2008,290,225,0.469,0.605 23 | 2000,2000,14374,1302,, 24 | 2000,2001,12237,5210,0.362,0.851 25 | 2000,2002,9760,5627,0.46,0.798 26 | 2000,2003,9316,5689,0.583,0.954 27 | 2000,2004,5458,6202,0.666,0.586 28 | 2000,2005,5605,4823,0.884,1.027 29 | 2000,2006,3727,4369,0.78,0.665 30 | 2000,2007,1603,2680,0.719,0.43 31 | 2000,2008,465,880,0.549,0.29 32 | 2001,2001,10288,1539,, 33 | 2001,2002,10052,4413,0.429,0.977 34 | 2001,2003,8703,6367,0.633,0.866 35 | 2001,2004,7969,6289,0.723,0.916 36 | 2001,2005,9818,5778,0.725,1.232 37 | 2001,2006,6046,6703,0.683,0.616 38 | 2001,2007,1471,5980,0.989,0.243 39 | 2001,2008,278,1450,0.985,0.189 40 | 2002,2002,10494,2318,, 41 | 2002,2003,12439,5614,0.535,1.185 42 | 2002,2004,12833,5891,0.474,1.032 43 | 2002,2005,15572,8273,0.645,1.213 44 | 2002,2006,12469,9850,0.633,0.801 45 | 2002,2007,8072,8683,0.696,0.647 46 | 2002,2008,3731,3809,0.472,0.462 47 | 2003,2003,7908,1743,, 48 | 2003,2004,10755,4497,0.569,1.36 49 | 2003,2005,17671,6443,0.599,1.643 50 | 2003,2006,17702,10209,0.578,1.002 51 | 2003,2007,9726,11613,0.656,0.549 52 | 2003,2008,5052,4815,0.495,0.519 53 | 2004,2004,14774,2221,, 54 | 2004,2005,30281,7677,0.52,2.05 55 | 2004,2006,32916,16052,0.53,1.087 56 | 2004,2007,28268,17489,0.531,0.859 57 | 2004,2008,17477,9372,0.332,0.618 58 | 2005,2005,25631,3043,, 59 | 2005,2006,35213,9176,0.358,1.374 60 | 2005,2007,43268,14854,0.422,1.229 61 | 2005,2008,30629,12953,0.299,0.708 62 | 2006,2006,23535,3531,, 63 | 2006,2007,35005,8247,0.35,1.487 64 | 2006,2008,25985,11041,0.315,0.742 65 | 2007,2007,15948,3529,, 66 | 2007,2008,19867,8336,0.523,1.246 67 | 2008,2008,15223,3409,, 68 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_xyz_disp.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Disposal Rate,Closed Claim Counts,Paid Claims 2 | 2001,2001,0.209,304,1539 3 | 2001,2002,0.468,681,5952 4 | 2001,2003,0.643,936,12319 5 | 2001,2004,0.751,1092,18609 6 | 2001,2005,0.842,1225,24387 7 | 2001,2006,0.933,1357,31090 8 | 2001,2007,0.984,1432,37070 9 | 2001,2008,0.994,1446,38519 10 | 2002,2002,0.131,203,2318 11 | 2002,2003,0.391,607,7932 12 | 2002,2004,0.541,841,13822 13 | 2002,2005,0.701,1089,22095 14 | 2002,2006,0.854,1327,31945 15 | 2002,2007,0.842,1464,40629 16 | 2002,2008,0.98,1523,44437 17 | 2003,2003,0.111,181,1743 18 | 2003,2004,0.377,614,6240 19 | 2003,2005,0.577,941,12683 20 | 2003,2006,0.775,1263,22892 21 | 2003,2007,0.924,1507,34505 22 | 2003,2008,0.962,1568,39320 23 | 2004,2004,0.104,235,2221 24 | 2004,2005,0.375,848,9898 25 | 2004,2006,0.637,1442,25950 26 | 2004,2007,0.819,1852,43439 27 | 2004,2008,0.897,2029,52811 28 | 2005,2005,0.123,295,3043 29 | 2005,2006,0.466,1119,12219 30 | 2005,2007,0.693,1664,27073 31 | 2005,2008,0.81,1946,40026 32 | 2006,2006,0.183,307,3531 33 | 2006,2007,0.54,906,11778 34 | 2006,2008,0.716,1201,22819 35 | 2007,2007,0.251,329,3529 36 | 2007,2008,0.605,791,11865 37 | 2008,2008,0.236,276,3409 38 | -------------------------------------------------------------------------------- /chainladder/utils/data/friedland_xyz_freq_sev.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Closed Claim Counts,Reported Claim Counts,Reported Claims,Reported Severities 2 | 1998,1998,,,, 3 | 1998,1999,,,, 4 | 1998,2000,,,1171000, 5 | 1998,2001,510,634,12380000,19526 6 | 1998,2002,547,635,13216000,20813 7 | 1998,2003,575,635,14067000,22152 8 | 1998,2004,598,637,14688000,23058 9 | 1998,2005,612,637,16366000,25692 10 | 1998,2006,620,637,16163000,25374 11 | 1998,2007,635,637,15835000,24859 12 | 1998,2008,637,637,15822000,24839 13 | 1999,1999,,,, 14 | 1999,2000,,,13255000, 15 | 1999,2001,686,1026,16405000,15989 16 | 1999,2002,819,1039,19639000,18902 17 | 1999,2003,910,1047,22473000,21464 18 | 1999,2004,980,1050,23764000,22632 19 | 1999,2005,1007,1053,25094000,23831 20 | 1999,2006,1036,1047,24795000,23682 21 | 1999,2007,1039,1047,25071000,23946 22 | 1999,2008,1044,1047,25107000,23980 23 | 2000,2000,,,15676000, 24 | 2000,2001,650,1354,18749000,13847 25 | 2000,2002,932,1397,21900000,15676 26 | 2000,2003,1095,1411,27144000,19237 27 | 2000,2004,1216,1410,29488000,20914 28 | 2000,2005,1292,1408,34458000,24473 29 | 2000,2006,1367,1408,36949000,26242 30 | 2000,2007,1391,1408,37505000,26637 31 | 2000,2008,1402,1408,37246000,26453 32 | 2001,2001,304,1305,11827000,9063 33 | 2001,2002,681,1421,16004000,11262 34 | 2001,2003,936,1449,21022000,14508 35 | 2001,2004,1092,1458,26578000,18229 36 | 2001,2005,1225,1458,34205000,23460 37 | 2001,2006,1357,1455,37136000,25523 38 | 2001,2007,1432,1455,38541000,26489 39 | 2001,2008,1446,1455,38798000,26665 40 | 2002,2002,203,1342,12811000,9546 41 | 2002,2003,607,1514,20370000,13455 42 | 2002,2004,841,1548,26656000,17219 43 | 2002,2005,1089,1557,37667000,24192 44 | 2002,2006,1327,1549,44414000,28673 45 | 2002,2007,1464,1552,48701000,31379 46 | 2002,2008,1523,1554,48169000,30997 47 | 2003,2003,181,1373,9651000,7029 48 | 2003,2004,614,1616,16995000,10517 49 | 2003,2005,941,1630,30354000,18622 50 | 2003,2006,1263,1626,40594000,24966 51 | 2003,2007,1507,1629,44231000,27152 52 | 2003,2008,1568,1629,44373000,27239 53 | 2004,2004,235,1932,16995000,8796 54 | 2004,2005,848,2168,40180000,18533 55 | 2004,2006,1442,2234,58866000,26350 56 | 2004,2007,1852,2249,71707000,31884 57 | 2004,2008,2029,2258,70288000,31129 58 | 2005,2005,295,2067,28674000,13872 59 | 2005,2006,1119,2293,47432000,20686 60 | 2005,2007,1664,2367,70340000,29717 61 | 2005,2008,1946,2390,70655000,29563 62 | 2006,2006,307,1473,27066000,18375 63 | 2006,2007,906,1645,46783000,28440 64 | 2006,2008,1201,1657,48804000,29453 65 | 2007,2007,329,1192,19477000,16340 66 | 2007,2008,791,1264,31732000,25104 67 | 2008,2008,276,1036,18632000,17985 68 | -------------------------------------------------------------------------------- /chainladder/utils/data/genins.csv: -------------------------------------------------------------------------------- 1 | development,origin,values 2 | 2001,2001,357848.0 3 | 2002,2002,352118.0 4 | 2003,2003,290507.0 5 | 2004,2004,310608.0 6 | 2005,2005,443160.0 7 | 2006,2006,396132.0 8 | 2007,2007,440832.0 9 | 2008,2008,359480.0 10 | 2009,2009,376686.0 11 | 2010,2010,344014.0 12 | 2002,2001,1124788.0 13 | 2003,2002,1236139.0 14 | 2004,2003,1292306.0 15 | 2005,2004,1418858.0 16 | 2006,2005,1136350.0 17 | 2007,2006,1333217.0 18 | 2008,2007,1288463.0 19 | 2009,2008,1421128.0 20 | 2010,2009,1363294.0 21 | 2003,2001,1735330.0 22 | 2004,2002,2170033.0 23 | 2005,2003,2218525.0 24 | 2006,2004,2195047.0 25 | 2007,2005,2128333.0 26 | 2008,2006,2180715.0 27 | 2009,2007,2419861.0 28 | 2010,2008,2864498.0 29 | 2004,2001,2218270.0 30 | 2005,2002,3353322.0 31 | 2006,2003,3235179.0 32 | 2007,2004,3757447.0 33 | 2008,2005,2897821.0 34 | 2009,2006,2985752.0 35 | 2010,2007,3483130.0 36 | 2005,2001,2745596.0 37 | 2006,2002,3799067.0 38 | 2007,2003,3985995.0 39 | 2008,2004,4029929.0 40 | 2009,2005,3402672.0 41 | 2010,2006,3691712.0 42 | 2006,2001,3319994.0 43 | 2007,2002,4120063.0 44 | 2008,2003,4132918.0 45 | 2009,2004,4381982.0 46 | 2010,2005,3873311.0 47 | 2007,2001,3466336.0 48 | 2008,2002,4647867.0 49 | 2009,2003,4628910.0 50 | 2010,2004,4588268.0 51 | 2008,2001,3606286.0 52 | 2009,2002,4914039.0 53 | 2010,2003,4909315.0 54 | 2009,2001,3833515.0 55 | 2010,2002,5339085.0 56 | 2010,2001,3901463.0 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/ia_sample.csv: -------------------------------------------------------------------------------- 1 | origin,development,loss,exposure 2 | 2000,2000,1001,4025 3 | 2001,2001,1113,4456 4 | 2002,2002,1265,5315 5 | 2003,2003,1490,5986 6 | 2004,2004,1725,6939 7 | 2005,2005,1889,8158 8 | 2000,2001,1855,4025 9 | 2001,2002,2103,4456 10 | 2002,2003,2433,5315 11 | 2003,2004,2873,5986 12 | 2004,2005,3261,6939 13 | 2000,2002,2423,4025 14 | 2001,2003,2774,4456 15 | 2002,2004,3233,5315 16 | 2003,2005,3880,5986 17 | 2000,2003,2988,4025 18 | 2001,2004,3422,4456 19 | 2002,2005,3977,5315 20 | 2000,2004,3335,4025 21 | 2001,2005,3844,4456 22 | 2000,2005,3483,4025 23 | -------------------------------------------------------------------------------- /chainladder/utils/data/m3ir5.csv: -------------------------------------------------------------------------------- 1 | development,origin,values 2 | 1978,1978,108651.0 3 | 1979,1979,98706.0 4 | 1980,1980,133106.0 5 | 1981,1981,125731.0 6 | 1982,1982,161765.0 7 | 1983,1983,226364.0 8 | 1984,1984,228411.0 9 | 1985,1985,277868.0 10 | 1986,1986,302519.0 11 | 1987,1987,393525.0 12 | 1988,1988,450855.0 13 | 1989,1989,572576.0 14 | 1990,1990,576021.0 15 | 1991,1991,580068.0 16 | 1979,1978,97529.0 17 | 1980,1979,95216.0 18 | 1981,1980,109743.0 19 | 1982,1981,141478.0 20 | 1983,1982,174888.0 21 | 1984,1983,203191.0 22 | 1985,1984,216837.0 23 | 1986,1985,262472.0 24 | 1987,1986,360015.0 25 | 1988,1987,388054.0 26 | 1989,1988,333667.0 27 | 1990,1989,568013.0 28 | 1991,1990,469724.0 29 | 1980,1978,75879.0 30 | 1981,1979,83025.0 31 | 1982,1980,96365.0 32 | 1983,1981,144336.0 33 | 1984,1982,168704.0 34 | 1985,1983,179136.0 35 | 1986,1984,242050.0 36 | 1987,1985,265375.0 37 | 1988,1986,343485.0 38 | 1989,1987,383425.0 39 | 1990,1988,398276.0 40 | 1991,1989,382277.0 41 | 1981,1978,69418.0 42 | 1982,1979,72396.0 43 | 1983,1980,130993.0 44 | 1984,1981,124854.0 45 | 1985,1982,156514.0 46 | 1986,1983,159835.0 47 | 1987,1984,249422.0 48 | 1988,1985,227499.0 49 | 1989,1986,224336.0 50 | 1990,1987,326081.0 51 | 1991,1988,382277.0 52 | 1982,1978,55542.0 53 | 1983,1979,104914.0 54 | 1984,1980,112860.0 55 | 1985,1981,107034.0 56 | 1986,1982,145495.0 57 | 1987,1983,156670.0 58 | 1988,1984,205644.0 59 | 1989,1985,221660.0 60 | 1990,1986,220334.0 61 | 1991,1987,271278.0 62 | 1983,1978,62875.0 63 | 1984,1979,94174.0 64 | 1985,1980,87108.0 65 | 1986,1981,122015.0 66 | 1987,1982,138954.0 67 | 1988,1983,153108.0 68 | 1989,1984,220996.0 69 | 1990,1985,247187.0 70 | 1991,1986,234427.0 71 | 1984,1978,63697.0 72 | 1985,1979,77103.0 73 | 1986,1980,99698.0 74 | 1987,1981,110514.0 75 | 1988,1982,125480.0 76 | 1989,1983,142187.0 77 | 1990,1984,169549.0 78 | 1991,1985,207918.0 79 | 1985,1978,72468.0 80 | 1986,1979,70538.0 81 | 1987,1980,92494.0 82 | 1988,1981,93517.0 83 | 1989,1982,106927.0 84 | 1990,1983,160637.0 85 | 1991,1984,166858.0 86 | 1986,1978,65114.0 87 | 1987,1979,71747.0 88 | 1988,1980,89224.0 89 | 1989,1981,95885.0 90 | 1990,1982,111179.0 91 | 1991,1983,139511.0 92 | 1987,1978,62436.0 93 | 1988,1979,77567.0 94 | 1989,1980,82117.0 95 | 1990,1981,97626.0 96 | 1991,1982,118054.0 97 | 1988,1978,57983.0 98 | 1989,1979,68934.0 99 | 1990,1980,78190.0 100 | 1991,1981,83692.0 101 | 1989,1978,56551.0 102 | 1990,1979,70467.0 103 | 1991,1980,78504.0 104 | 1990,1978,48528.0 105 | 1991,1979,43560.0 106 | 1991,1978,39023.0 107 | -------------------------------------------------------------------------------- /chainladder/utils/data/mack_1997.csv: -------------------------------------------------------------------------------- 1 | Accident Year,Calendar Year,Case Incurred 2 | 1991,1991,5012 3 | 1991,1992,8269 4 | 1991,1993,10907 5 | 1991,1994,11805 6 | 1991,1995,13539 7 | 1991,1996,16181 8 | 1991,1997,18009 9 | 1991,1998,18608 10 | 1991,1999,18662 11 | 1991,2000,18834 12 | 1992,1992,106 13 | 1992,1993,4285 14 | 1992,1994,5396 15 | 1992,1995,10666 16 | 1992,1996,13782 17 | 1992,1997,15599 18 | 1992,1998,15496 19 | 1992,1999,16169 20 | 1992,2000,16704 21 | 1993,1993,3410 22 | 1993,1994,8992 23 | 1993,1995,13873 24 | 1993,1996,16141 25 | 1993,1997,18735 26 | 1993,1998,22214 27 | 1993,1999,22863 28 | 1993,2000,23466 29 | 1994,1994,5655 30 | 1994,1995,11555 31 | 1994,1996,15766 32 | 1994,1997,21266 33 | 1994,1998,23425 34 | 1994,1999,26083 35 | 1994,2000,27067 36 | 1995,1995,1092 37 | 1995,1996,9565 38 | 1995,1997,15836 39 | 1995,1998,22169 40 | 1995,1999,25955 41 | 1995,2000,26180 42 | 1996,1996,1513 43 | 1996,1997,6445 44 | 1996,1998,11702 45 | 1996,1999,12935 46 | 1996,2000,15852 47 | 1997,1997,557 48 | 1997,1998,4020 49 | 1997,1999,10946 50 | 1997,2000,12314 51 | 1998,1998,1351 52 | 1998,1999,6947 53 | 1998,2000,13112 54 | 1999,1999,3133 55 | 1999,2000,5395 56 | 2000,2000,2063 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/mcl.csv: -------------------------------------------------------------------------------- 1 | development,origin,incurred,paid 2 | 2001,2001,978.0,576.0 3 | 2002,2002,1844.0,866.0 4 | 2003,2003,2904.0,1412.0 5 | 2004,2004,3502.0,2286.0 6 | 2005,2005,2812.0,1868.0 7 | 2006,2006,2642.0,1442.0 8 | 2007,2007,5022.0,2044.0 9 | 2002,2001,2104.0,1804.0 10 | 2003,2002,2552.0,1948.0 11 | 2004,2003,4354.0,3758.0 12 | 2005,2004,5958.0,5292.0 13 | 2006,2005,4882.0,3778.0 14 | 2007,2006,4406.0,4010.0 15 | 2003,2001,2134.0,1970.0 16 | 2004,2002,2466.0,2162.0 17 | 2005,2003,4698.0,4252.0 18 | 2006,2004,6070.0,5724.0 19 | 2007,2005,4852.0,4648.0 20 | 2004,2001,2144.0,2024.0 21 | 2005,2002,2480.0,2232.0 22 | 2006,2003,4600.0,4416.0 23 | 2007,2004,6142.0,5850.0 24 | 2005,2001,2174.0,2074.0 25 | 2006,2002,2508.0,2284.0 26 | 2007,2003,4644.0,4494.0 27 | 2006,2001,2182.0,2102.0 28 | 2007,2002,2454.0,2348.0 29 | 2007,2001,2174.0,2131.0 30 | -------------------------------------------------------------------------------- /chainladder/utils/data/mortgage.csv: -------------------------------------------------------------------------------- 1 | development,origin,values 2 | 2001,2001,58046.0 3 | 2002,2002,24492.0 4 | 2003,2003,32848.0 5 | 2004,2004,21439.0 6 | 2005,2005,40397.0 7 | 2006,2006,90748.0 8 | 2007,2007,62096.0 9 | 2008,2008,24983.0 10 | 2009,2009,13121.0 11 | 2002,2001,127970.0 12 | 2003,2002,141767.0 13 | 2004,2003,274682.0 14 | 2005,2004,529828.0 15 | 2006,2005,763394.0 16 | 2007,2006,951994.0 17 | 2008,2007,868480.0 18 | 2009,2008,284441.0 19 | 2003,2001,476599.0 20 | 2004,2002,984288.0 21 | 2005,2003,1522637.0 22 | 2006,2004,2900301.0 23 | 2007,2005,2920745.0 24 | 2008,2006,4210640.0 25 | 2009,2007,1954797.0 26 | 2004,2001,1027692.0 27 | 2005,2002,2142656.0 28 | 2006,2003,3203427.0 29 | 2007,2004,4999019.0 30 | 2008,2005,4989572.0 31 | 2009,2006,5866482.0 32 | 2005,2001,1360489.0 33 | 2006,2002,2961978.0 34 | 2007,2003,4445927.0 35 | 2008,2004,6460112.0 36 | 2009,2005,5648563.0 37 | 2006,2001,1647310.0 38 | 2007,2002,3683940.0 39 | 2008,2003,5158781.0 40 | 2009,2004,6853904.0 41 | 2007,2001,1819179.0 42 | 2008,2002,4048898.0 43 | 2009,2003,5342585.0 44 | 2008,2001,1906852.0 45 | 2009,2002,4115760.0 46 | 2009,2001,1950105.0 47 | -------------------------------------------------------------------------------- /chainladder/utils/data/mw2008.csv: -------------------------------------------------------------------------------- 1 | development,origin,values 2 | 2001,2001,2202584.0 3 | 2002,2002,2350650.0 4 | 2003,2003,2321885.0 5 | 2004,2004,2171487.0 6 | 2005,2005,2140328.0 7 | 2006,2006,2290664.0 8 | 2007,2007,2148216.0 9 | 2008,2008,2143728.0 10 | 2009,2009,2144738.0 11 | 2002,2001,3210449.0 12 | 2003,2002,3553023.0 13 | 2004,2003,3424190.0 14 | 2005,2004,3165274.0 15 | 2006,2005,3157079.0 16 | 2007,2006,3338197.0 17 | 2008,2007,3219775.0 18 | 2009,2008,3158581.0 19 | 2003,2001,3468122.0 20 | 2004,2002,3783846.0 21 | 2005,2003,3700876.0 22 | 2006,2004,3395841.0 23 | 2007,2005,3399262.0 24 | 2008,2006,3550332.0 25 | 2009,2007,3428335.0 26 | 2004,2001,3545070.0 27 | 2005,2002,3840067.0 28 | 2006,2003,3798198.0 29 | 2007,2004,3466453.0 30 | 2008,2005,3500520.0 31 | 2009,2006,3641036.0 32 | 2005,2001,3621627.0 33 | 2006,2002,3865187.0 34 | 2007,2003,3854755.0 35 | 2008,2004,3515703.0 36 | 2009,2005,3585812.0 37 | 2006,2001,3644636.0 38 | 2007,2002,3878744.0 39 | 2008,2003,3878993.0 40 | 2009,2004,3548422.0 41 | 2007,2001,3669012.0 42 | 2008,2002,3898281.0 43 | 2009,2003,3898825.0 44 | 2008,2001,3674511.0 45 | 2009,2002,3902425.0 46 | 2009,2001,3678633.0 47 | -------------------------------------------------------------------------------- /chainladder/utils/data/mw2014.csv: -------------------------------------------------------------------------------- 1 | development,origin,values 2 | 2001,2001,13109.0 3 | 2002,2002,14457.0 4 | 2003,2003,16075.0 5 | 2004,2004,15682.0 6 | 2005,2005,16551.0 7 | 2006,2006,15439.0 8 | 2007,2007,14629.0 9 | 2008,2008,17585.0 10 | 2009,2009,17419.0 11 | 2010,2010,16665.0 12 | 2011,2011,15471.0 13 | 2012,2012,15103.0 14 | 2013,2013,14540.0 15 | 2014,2014,14590.0 16 | 2015,2015,13967.0 17 | 2016,2016,12930.0 18 | 2017,2017,12539.0 19 | 2002,2001,20355.0 20 | 2003,2002,22038.0 21 | 2004,2003,22672.0 22 | 2005,2004,23464.0 23 | 2006,2005,23706.0 24 | 2007,2006,23796.0 25 | 2008,2007,21645.0 26 | 2009,2008,26288.0 27 | 2010,2009,25941.0 28 | 2011,2010,25370.0 29 | 2012,2011,23745.0 30 | 2013,2012,23393.0 31 | 2014,2013,22642.0 32 | 2015,2014,22336.0 33 | 2016,2015,21515.0 34 | 2017,2016,20111.0 35 | 2003,2001,21337.0 36 | 2004,2002,22627.0 37 | 2005,2003,23753.0 38 | 2006,2004,24465.0 39 | 2007,2005,24627.0 40 | 2008,2006,24866.0 41 | 2009,2007,22826.0 42 | 2010,2008,27623.0 43 | 2011,2009,27066.0 44 | 2012,2010,26909.0 45 | 2013,2011,25117.0 46 | 2014,2012,26809.0 47 | 2015,2013,23571.0 48 | 2016,2014,23440.0 49 | 2017,2015,22603.0 50 | 2004,2001,22043.0 51 | 2005,2002,23114.0 52 | 2006,2003,24052.0 53 | 2007,2004,25052.0 54 | 2008,2005,25573.0 55 | 2009,2006,25317.0 56 | 2010,2007,23599.0 57 | 2011,2008,27939.0 58 | 2012,2009,27761.0 59 | 2013,2010,27611.0 60 | 2014,2011,26378.0 61 | 2015,2012,27691.0 62 | 2016,2013,24127.0 63 | 2017,2014,24029.0 64 | 2005,2001,22401.0 65 | 2006,2002,23238.0 66 | 2007,2003,24206.0 67 | 2008,2004,25529.0 68 | 2009,2005,26046.0 69 | 2010,2006,26139.0 70 | 2011,2007,24992.0 71 | 2012,2008,28335.0 72 | 2013,2009,28043.0 73 | 2014,2010,27729.0 74 | 2015,2011,26971.0 75 | 2016,2012,28061.0 76 | 2017,2013,24210.0 77 | 2006,2001,22658.0 78 | 2007,2002,23312.0 79 | 2008,2003,24757.0 80 | 2009,2004,25708.0 81 | 2010,2005,26115.0 82 | 2011,2006,26154.0 83 | 2012,2007,25434.0 84 | 2013,2008,28638.0 85 | 2014,2009,28477.0 86 | 2015,2010,27861.0 87 | 2016,2011,27396.0 88 | 2017,2012,29183.0 89 | 2007,2001,22997.0 90 | 2008,2002,23440.0 91 | 2009,2003,24786.0 92 | 2010,2004,25752.0 93 | 2011,2005,26283.0 94 | 2012,2006,26175.0 95 | 2013,2007,25476.0 96 | 2014,2008,28715.0 97 | 2015,2009,28721.0 98 | 2016,2010,29830.0 99 | 2017,2011,27480.0 100 | 2008,2001,23158.0 101 | 2009,2002,23490.0 102 | 2010,2003,24807.0 103 | 2011,2004,25770.0 104 | 2012,2005,26481.0 105 | 2013,2006,26205.0 106 | 2014,2007,25549.0 107 | 2015,2008,28759.0 108 | 2016,2009,28878.0 109 | 2017,2010,29844.0 110 | 2009,2001,23492.0 111 | 2010,2002,23964.0 112 | 2011,2003,24823.0 113 | 2012,2004,25835.0 114 | 2013,2005,26701.0 115 | 2014,2006,26764.0 116 | 2015,2007,25604.0 117 | 2016,2008,29525.0 118 | 2017,2009,28948.0 119 | 2010,2001,23664.0 120 | 2011,2002,23976.0 121 | 2012,2003,24888.0 122 | 2013,2004,26075.0 123 | 2014,2005,26718.0 124 | 2015,2006,26818.0 125 | 2016,2007,25709.0 126 | 2017,2008,30302.0 127 | 2011,2001,23699.0 128 | 2012,2002,24048.0 129 | 2013,2003,24986.0 130 | 2014,2004,26082.0 131 | 2015,2005,26724.0 132 | 2016,2006,26836.0 133 | 2017,2007,25723.0 134 | 2012,2001,23904.0 135 | 2013,2002,24111.0 136 | 2014,2003,25401.0 137 | 2015,2004,26146.0 138 | 2016,2005,26728.0 139 | 2017,2006,26959.0 140 | 2013,2001,23960.0 141 | 2014,2002,24252.0 142 | 2015,2003,25681.0 143 | 2016,2004,26150.0 144 | 2017,2005,26735.0 145 | 2014,2001,23992.0 146 | 2015,2002,24538.0 147 | 2016,2003,25705.0 148 | 2017,2004,26167.0 149 | 2015,2001,23994.0 150 | 2016,2002,24540.0 151 | 2017,2003,25732.0 152 | 2016,2001,24001.0 153 | 2017,2002,24550.0 154 | 2017,2001,24002.0 155 | -------------------------------------------------------------------------------- /chainladder/utils/data/raa.csv: -------------------------------------------------------------------------------- 1 | development,origin,values 2 | 1981,1981,5012.0 3 | 1982,1982,106.0 4 | 1983,1983,3410.0 5 | 1984,1984,5655.0 6 | 1985,1985,1092.0 7 | 1986,1986,1513.0 8 | 1987,1987,557.0 9 | 1988,1988,1351.0 10 | 1989,1989,3133.0 11 | 1990,1990,2063.0 12 | 1982,1981,8269.0 13 | 1983,1982,4285.0 14 | 1984,1983,8992.0 15 | 1985,1984,11555.0 16 | 1986,1985,9565.0 17 | 1987,1986,6445.0 18 | 1988,1987,4020.0 19 | 1989,1988,6947.0 20 | 1990,1989,5395.0 21 | 1983,1981,10907.0 22 | 1984,1982,5396.0 23 | 1985,1983,13873.0 24 | 1986,1984,15766.0 25 | 1987,1985,15836.0 26 | 1988,1986,11702.0 27 | 1989,1987,10946.0 28 | 1990,1988,13112.0 29 | 1984,1981,11805.0 30 | 1985,1982,10666.0 31 | 1986,1983,16141.0 32 | 1987,1984,21266.0 33 | 1988,1985,22169.0 34 | 1989,1986,12935.0 35 | 1990,1987,12314.0 36 | 1985,1981,13539.0 37 | 1986,1982,13782.0 38 | 1987,1983,18735.0 39 | 1988,1984,23425.0 40 | 1989,1985,25955.0 41 | 1990,1986,15852.0 42 | 1986,1981,16181.0 43 | 1987,1982,15599.0 44 | 1988,1983,22214.0 45 | 1989,1984,26083.0 46 | 1990,1985,26180.0 47 | 1987,1981,18009.0 48 | 1988,1982,15496.0 49 | 1989,1983,22863.0 50 | 1990,1984,27067.0 51 | 1988,1981,18608.0 52 | 1989,1982,16169.0 53 | 1990,1983,23466.0 54 | 1989,1981,18662.0 55 | 1990,1982,16704.0 56 | 1990,1981,18834.0 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/tail_sample.csv: -------------------------------------------------------------------------------- 1 | development,origin,incurred,paid 2 | 2000,2000,2539,1202 3 | 2001,2001,2672,1297 4 | 2002,2002,2808,1342 5 | 2003,2003,3073,1293 6 | 2004,2004,3070,1387 7 | 2005,2005,2932,1487 8 | 2006,2006,3095,1499 9 | 2007,2007,3228,1587 10 | 2008,2008,2877,1221 11 | 2009,2009,2890,1321 12 | 2001,2000,4479,2685 13 | 2002,2001,4667,2712 14 | 2003,2002,4676,2566 15 | 2004,2003,5099,2716 16 | 2005,2004,4527,2555 17 | 2006,2005,4750,2738 18 | 2007,2006,5104,2920 19 | 2008,2007,5526,3287 20 | 2009,2008,5122,2775 21 | 2002,2000,5650,4132 22 | 2003,2001,6049,4232 23 | 2004,2002,6207,4058 24 | 2005,2003,6292,4228 25 | 2006,2004,5915,4017 26 | 2007,2005,6041,4125 27 | 2008,2006,6770,4781 28 | 2009,2007,7204,5006 29 | 2003,2000,6639,5323 30 | 2004,2001,6988,5314 31 | 2005,2002,7064,5388 32 | 2006,2003,7237,5587 33 | 2007,2004,6986,5460 34 | 2008,2005,7144,5683 35 | 2009,2006,7821,6285 36 | 2004,2000,7224,6059 37 | 2005,2001,7355,6062 38 | 2006,2002,7601,6480 39 | 2007,2003,7749,6661 40 | 2008,2004,7780,6743 41 | 2009,2005,7771,6793 42 | 2005,2000,7224,6406 43 | 2006,2001,7819,6786 44 | 2007,2002,7984,7141 45 | 2008,2003,8386,7626 46 | 2009,2004,8197,7479 47 | 2006,2000,7464,6812 48 | 2007,2001,8171,7375 49 | 2008,2002,8390,7801 50 | 2009,2003,8604,8040 51 | 2007,2000,7778,7208 52 | 2008,2001,8296,7687 53 | 2009,2002,8628,8109 54 | 2008,2000,7892,7440 55 | 2009,2001,8518,7934 56 | 2009,2000,7987,7618 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/ukmotor.csv: -------------------------------------------------------------------------------- 1 | development,origin,values 2 | 2007,2007,3511.0 3 | 2008,2008,4001.0 4 | 2009,2009,4355.0 5 | 2010,2010,4295.0 6 | 2011,2011,4150.0 7 | 2012,2012,5102.0 8 | 2013,2013,6283.0 9 | 2008,2007,6726.0 10 | 2009,2008,7703.0 11 | 2010,2009,8287.0 12 | 2011,2010,7750.0 13 | 2012,2011,7897.0 14 | 2013,2012,9650.0 15 | 2009,2007,8992.0 16 | 2010,2008,9981.0 17 | 2011,2009,10233.0 18 | 2012,2010,9773.0 19 | 2013,2011,10217.0 20 | 2010,2007,10704.0 21 | 2011,2008,11161.0 22 | 2012,2009,11755.0 23 | 2013,2010,11093.0 24 | 2011,2007,11763.0 25 | 2012,2008,12117.0 26 | 2013,2009,12993.0 27 | 2012,2007,12350.0 28 | 2013,2008,12746.0 29 | 2013,2007,12690.0 30 | -------------------------------------------------------------------------------- /chainladder/utils/data/usaa.csv: -------------------------------------------------------------------------------- 1 | development,origin,incurred,paid 2 | 2000,2000,1004718.0,271778.0 3 | 2001,2001,1087641.0,296828.0 4 | 2002,2002,1241178.0,334331.0 5 | 2003,2003,1333590.0,354530.0 6 | 2004,2004,1532336.0,423048.0 7 | 2005,2005,1777164.0,484849.0 8 | 2006,2006,1892532.0,541361.0 9 | 2007,2007,1577620.0,547102.0 10 | 2008,2008,1669006.0,561687.0 11 | 2009,2009,1326522.0,542021.0 12 | 2001,2000,943338.0,530060.0 13 | 2002,2001,1038985.0,601823.0 14 | 2003,2002,1189747.0,676028.0 15 | 2004,2003,1290793.0,741578.0 16 | 2005,2004,1480702.0,855543.0 17 | 2006,2005,1634241.0,955067.0 18 | 2007,2006,1674298.0,1016328.0 19 | 2008,2007,1548129.0,986025.0 20 | 2009,2008,1418105.0,966162.0 21 | 2002,2000,904527.0,700671.0 22 | 2003,2001,1030782.0,780171.0 23 | 2004,2002,1166289.0,878584.0 24 | 2005,2003,1274984.0,950130.0 25 | 2006,2004,1408227.0,1061020.0 26 | 2007,2005,1566779.0,1171931.0 27 | 2008,2006,1462731.0,1214955.0 28 | 2009,2007,1417382.0,1185300.0 29 | 2003,2000,903953.0,783609.0 30 | 2004,2001,1019298.0,888761.0 31 | 2005,2002,1140782.0,990678.0 32 | 2006,2003,1235943.0,1063478.0 33 | 2007,2004,1303835.0,1157675.0 34 | 2008,2005,1391535.0,1270740.0 35 | 2009,2006,1438025.0,1320130.0 36 | 2004,2000,907103.0,844980.0 37 | 2005,2001,1015535.0,944970.0 38 | 2006,2002,1124084.0,1039004.0 39 | 2007,2003,1189132.0,1112208.0 40 | 2008,2004,1262138.0,1204510.0 41 | 2009,2005,1378086.0,1324732.0 42 | 2005,2000,908622.0,870606.0 43 | 2006,2001,1009769.0,968118.0 44 | 2007,2002,1104031.0,1061058.0 45 | 2008,2003,1157715.0,1131215.0 46 | 2009,2004,1253181.0,1226650.0 47 | 2006,2000,906790.0,879943.0 48 | 2007,2001,998765.0,976165.0 49 | 2008,2002,1092985.0,1070862.0 50 | 2009,2003,1151469.0,1138375.0 51 | 2007,2000,900625.0,883870.0 52 | 2008,2001,994009.0,979221.0 53 | 2009,2002,1086891.0,1075537.0 54 | 2008,2000,897725.0,885627.0 55 | 2009,2001,989663.0,982148.0 56 | 2009,2000,893764.0,886334.0 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/usauto.csv: -------------------------------------------------------------------------------- 1 | origin,development,incurred,paid 2 | 1998,1998,37017487,18539254 3 | 1999,1999,38954484,20410193 4 | 2000,2000,41155776,22120843 5 | 2001,2001,42394069,22992259 6 | 2002,2002,44755243,24092782 7 | 2003,2003,45163102,24084451 8 | 2004,2004,45417309,24369770 9 | 2005,2005,46360869,25100697 10 | 2006,2006,46582684,25608776 11 | 2007,2007,48853563,27229969 12 | 1998,1999,43169009,33231039 13 | 1999,2000,46045718,36090684 14 | 2000,2001,49371478,38976014 15 | 2001,2002,50584112,40096198 16 | 2002,2003,52971643,41795313 17 | 2003,2004,52497731,41399612 18 | 2004,2005,52640322,41489863 19 | 2005,2006,53790061,42702229 20 | 2006,2007,54641339,43606497 21 | 1998,2000,45568919,40062008 22 | 1999,2001,48882924,43259402 23 | 2000,2002,52358476,46389282 24 | 2001,2003,53704296,47767835 25 | 2002,2004,56102312,49903803 26 | 2003,2005,55468551,49070332 27 | 2004,2006,55553673,49236678 28 | 2005,2007,56786410,50644994 29 | 1998,2001,46784558,43892039 30 | 1999,2002,50219672,47159241 31 | 2000,2003,53780322,50562385 32 | 2001,2004,55150118,52093916 33 | 2002,2005,57703851,54352884 34 | 2003,2006,57015411,53584201 35 | 2004,2007,56976657,53774672 36 | 1998,2002,47337318,45896535 37 | 1999,2003,50729292,49208532 38 | 2000,2004,54303086,52735280 39 | 2001,2005,55895583,54363436 40 | 2002,2006,58363564,56754376 41 | 2003,2007,57565344,55930654 42 | 1998,2003,47533264,46765422 43 | 1999,2004,50926779,50162043 44 | 2000,2005,54582950,53740101 45 | 2001,2006,56156727,55378801 46 | 2002,2007,58592712,57807215 47 | 1998,2004,47634419,47221322 48 | 1999,2005,51069285,50625757 49 | 2000,2006,54742188,54284334 50 | 2001,2007,56299562,55878421 51 | 1998,2005,47689655,47446877 52 | 1999,2006,51163540,50878808 53 | 2000,2007,54837929,54533225 54 | 1998,2006,47724678,47555456 55 | 1999,2007,51185767,51000534 56 | 1998,2007,47742304,47644187 57 | -------------------------------------------------------------------------------- /chainladder/utils/data/xyz.csv: -------------------------------------------------------------------------------- 1 | AccidentYear,DevelopmentYear,Incurred,Paid,Reported,Closed,Premium 2 | 2002,2002,12811,2318,1342,203,61183 3 | 2003,2003,9651,1743,1373,181,69175 4 | 2004,2004,16995,2221,1932,235,99322 5 | 2005,2005,28674,3043,2067,295,138151 6 | 2006,2006,27066,3531,1473,307,107578 7 | 2007,2007,19477,3529,1192,329,62438 8 | 2008,2008,18632,3409,1036,276,47797 9 | 2002,2003,20370,7932,1514,607,61183 10 | 2003,2004,16995,6240,1616,614,69175 11 | 2004,2005,40180,9898,2168,848,99322 12 | 2005,2006,47432,12219,2293,1119,138151 13 | 2006,2007,46783,11778,1645,906,107578 14 | 2007,2008,31732,11865,1264,791,62438 15 | 2002,2004,26656,13822,1548,841,61183 16 | 2003,2005,30354,12683,1630,941,69175 17 | 2004,2006,58866,25950,2234,1442,99322 18 | 2005,2007,70340,27073,2367,1664,138151 19 | 2006,2008,48804,22819,1657,1201,107578 20 | 2002,2005,37667,22095,1557,1089,61183 21 | 2003,2006,40594,22892,1626,1263,69175 22 | 2004,2007,71707,43439,2249,1852,99322 23 | 2005,2008,70655,40026,2390,1946,138151 24 | 2002,2006,44414,31945,1549,1327,61183 25 | 2003,2007,44231,34505,1629,1507,69175 26 | 2004,2008,70288,52811,2258,2029,99322 27 | 2002,2007,48701,40629,1552,1464,61183 28 | 2003,2008,44373,39320,1629,1568,69175 29 | 2002,2008,48169,44437,1554,1523,61183 30 | 1998,2000,11171,6309,0,0,20000 31 | 1998,2001,12380,8521,634,510,20000 32 | 1998,2002,13216,10082,635,547,20000 33 | 1998,2003,14067,11620,635,575,20000 34 | 1998,2004,14688,13242,637,598,20000 35 | 1998,2005,16366,14419,637,612,20000 36 | 1998,2006,16163,15311,637,620,20000 37 | 1998,2007,15835,15764,637,635,20000 38 | 1998,2008,15822,15822,637,637,20000 39 | 1999,2000,13255,4666,0,0,31500 40 | 1999,2001,16405,9861,1026,686,31500 41 | 1999,2002,19639,13971,1039,819,31500 42 | 1999,2003,22473,18127,1047,910,31500 43 | 1999,2004,23764,22032,1050,980,31500 44 | 1999,2005,25094,23511,1053,1007,31500 45 | 1999,2006,24795,24146,1047,1036,31500 46 | 1999,2007,25071,24592,1047,1039,31500 47 | 1999,2008,25107,24817,1047,1044,31500 48 | 2000,2000,15676,1302,0,0,45000 49 | 2000,2001,18749,6513,1354,650,45000 50 | 2000,2002,21900,12139,1397,932,45000 51 | 2000,2003,27144,17828,1411,1095,45000 52 | 2000,2004,29488,24030,1410,1216,45000 53 | 2000,2005,34458,28853,1408,1292,45000 54 | 2000,2006,36949,33222,1408,1367,45000 55 | 2000,2007,37505,35902,1408,1391,45000 56 | 2000,2008,37246,36782,1408,1402,45000 57 | 2001,2001,11827,1539,1305,304,50000 58 | 2001,2002,16004,5952,1421,681,50000 59 | 2001,2003,21022,12319,1449,936,50000 60 | 2001,2004,26578,18609,1458,1092,50000 61 | 2001,2005,34205,24387,1458,1225,50000 62 | 2001,2006,37136,31090,1455,1357,50000 63 | 2001,2007,38541,37070,1455,1432,50000 64 | 2001,2008,38798,38519,1455,1446,50000 65 | -------------------------------------------------------------------------------- /chainladder/utils/sparse.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | import numpy as np 5 | import sparse 6 | from sparse import COO as sp 7 | from sparse import elemwise 8 | import pandas as pd 9 | import copy 10 | 11 | sp.isnan = np.isnan 12 | sp.newaxis = np.newaxis 13 | sp.nan = np.array([1.0, np.nan])[-1] 14 | sp.testing = np.testing 15 | sp.nansum = sparse.nansum 16 | sp.nanmin = sparse.nanmin 17 | sp.nanmax = sparse.nanmax 18 | sp.concatenate = sparse.concatenate 19 | sp.diagonal = sparse.diagonal 20 | sp.zeros = sparse.zeros 21 | sp.testing.assert_array_equal = np.testing.assert_equal 22 | sp.sqrt = np.sqrt 23 | sp.log = np.log 24 | sp.exp = np.exp 25 | sp.abs = np.abs 26 | 27 | 28 | def nan_to_num(a): 29 | if type(a) in [int, float, np.int64, np.float64]: 30 | return np.nan_to_num(a) 31 | if hasattr(a, "fill_value"): 32 | a = a.copy() 33 | a.data[np.isnan(a.data)] = 0.0 34 | return sp(coords=a.coords, data=a.data, fill_value=0.0, shape=a.shape) 35 | 36 | 37 | def ones(*args, **kwargs): 38 | return sp(np.ones(*args, **kwargs), fill_value=sp.nan) 39 | 40 | 41 | def nansum(a, axis=None, keepdims=None, *args, **kwargs): 42 | return sp(data=a.data, coords=a.coords, fill_value=0.0, shape=a.shape).sum( 43 | axis=axis, keepdims=keepdims, *args, **kwargs 44 | ) 45 | sp.nansum = nansum 46 | 47 | 48 | def nanmean(a, axis=None, keepdims=None, *args, **kwargs): 49 | n = sp.nansum(a, axis=axis, keepdims=keepdims) 50 | d = sp.nansum(sp.nan_to_num(a) != 0, axis=axis, keepdims=keepdims).astype(n.dtype) 51 | n = sp(data=n.data, coords=n.coords, fill_value=np.nan, shape=n.shape) 52 | d = sp(data=d.data, coords=d.coords, fill_value=np.nan, shape=d.shape) 53 | out = n / d 54 | return sp(data=out.data, coords=out.coords, fill_value=0, shape=out.shape) 55 | 56 | def array(a, *args, **kwargs): 57 | if kwargs.get("fill_value", None) is not None: 58 | fill_value = kwargs.pop("fill_value") 59 | else: 60 | fill_value = sp.nan 61 | if type(a) == sp: 62 | return sp(a, *args, **kwargs, fill_value=fill_value) 63 | else: 64 | return sp(np.array(a, *args, **kwargs), fill_value=fill_value) 65 | 66 | 67 | def arange(*args, **kwargs): 68 | return sparse.COO.from_numpy(np.arange(*args, **kwargs)) 69 | 70 | 71 | def where(*args, **kwargs): 72 | return elemwise(np.where, *args, **kwargs) 73 | 74 | 75 | def cumprod(a, axis=None, dtype=None, out=None): 76 | return array(np.cumprod(a.todense(), axis=axis, dtype=dtype, out=out)) 77 | 78 | 79 | def floor(x, *args, **kwargs): 80 | x.data = np.floor(x.data) 81 | return x 82 | 83 | 84 | 85 | sp.minimum = np.minimum 86 | sp.maximum = np.maximum 87 | sp.floor = floor 88 | sp.where = where 89 | sp.arange = arange 90 | sp.array = array 91 | sp.nan_to_num = nan_to_num 92 | sp.ones = ones 93 | sp.cumprod = cumprod 94 | sp.nanmean = nanmean 95 | -------------------------------------------------------------------------------- /chainladder/utils/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/chainladder/utils/tests/__init__.py -------------------------------------------------------------------------------- /chainladder/workflow/__init__.py: -------------------------------------------------------------------------------- 1 | from chainladder.workflow.gridsearch import GridSearch, Pipeline # noqa (API import) 2 | from chainladder.workflow.voting import VotingChainladder # noqa (API import) 3 | -------------------------------------------------------------------------------- /chainladder/workflow/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/chainladder/workflow/tests/__init__.py -------------------------------------------------------------------------------- /chainladder/workflow/tests/test_predict.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import chainladder as cl 3 | 4 | raa = cl.load_sample("RAA") 5 | raa_1989 = raa[raa.valuation < raa.valuation_date] 6 | raa_1990 = raa[raa.origin > "1981"] 7 | raa_1990 = raa_1990[raa_1990.valuation <= raa_1990.valuation_date] 8 | cl_ult = cl.Chainladder().fit(raa).ultimate_ # Chainladder Ultimate 9 | apriori = cl_ult * 0 + (float(cl_ult.sum()) / 10) # Mean Chainladder Ultimate 10 | apriori_1989 = apriori[apriori.origin < "1990"] 11 | apriori_1990 = apriori[apriori.origin > "1981"] 12 | 13 | 14 | def test_voting_predict(): 15 | bcl = cl.Chainladder() 16 | bf = cl.BornhuetterFerguson() 17 | cc = cl.CapeCod() 18 | 19 | estimators = [('bcl', bcl), ('bf', bf), ('cc', cc)] 20 | weights = np.array([[1, 2, 3]] * 3 + [[0, 0.5, 0.5]] * 3 + [[0, 0, 1]] * 3) 21 | 22 | vot = cl.VotingChainladder( 23 | estimators=estimators, 24 | weights=weights 25 | ).fit( 26 | raa_1989, 27 | sample_weight=apriori_1989, 28 | ) 29 | vot.predict(raa_1990, sample_weight=apriori_1990) 30 | -------------------------------------------------------------------------------- /chainladder/workflow/tests/test_workflow.py: -------------------------------------------------------------------------------- 1 | import chainladder as cl 2 | import pytest 3 | 4 | def test_grid(clrd): 5 | # Load Data 6 | medmal_paid = clrd.groupby("LOB").sum().loc["medmal"]["CumPaidLoss"] 7 | medmal_prem = ( 8 | clrd.groupby("LOB").sum().loc["medmal"]["EarnedPremDIR"].latest_diagonal 9 | ) 10 | 11 | # Pipeline 12 | dev = cl.Development() 13 | tail = cl.TailCurve() 14 | benk = cl.Benktander() 15 | 16 | steps = [("dev", dev), ("tail", tail), ("benk", benk)] 17 | pipe = cl.Pipeline(steps) 18 | 19 | # Prep Benktander Grid Search with various assumptions, and a scoring function 20 | param_grid = dict(benk__n_iters=[250], benk__apriori=[1.00]) 21 | scoring = {"IBNR": lambda x: x.named_steps.benk.ibnr_.sum()} 22 | 23 | grid = cl.GridSearch(pipe, param_grid, scoring=scoring) 24 | # Perform Grid Search 25 | grid.fit(medmal_paid, benk__sample_weight=medmal_prem) 26 | assert ( 27 | grid.results_["IBNR"][0] 28 | == cl.Benktander(n_iters=250, apriori=1) 29 | .fit( 30 | cl.TailCurve().fit_transform(cl.Development().fit_transform(medmal_paid)), 31 | sample_weight=medmal_prem, 32 | ) 33 | .ibnr_.sum() 34 | ) 35 | 36 | 37 | @pytest.fixture 38 | def tri(clrd): 39 | tri = clrd.groupby('LOB').sum()[['CumPaidLoss', 'IncurLoss', 'EarnedPremDIR']] 40 | tri['CaseIncurredLoss'] = tri['IncurLoss'] - tri['CumPaidLoss'] 41 | return tri 42 | 43 | dev = [cl.Development, cl.ClarkLDF, cl.Trend, cl.IncrementalAdditive, 44 | lambda : cl.MunichAdjustment(paid_to_incurred=('CumPaidLoss', 'CaseIncurredLoss')), 45 | lambda :cl.CaseOutstanding(paid_to_incurred=('CumPaidLoss', 'CaseIncurredLoss'))] 46 | tail = [cl.TailCurve, cl.TailConstant, cl.TailBondy, cl.TailClark] 47 | ibnr = [cl.Chainladder, cl.BornhuetterFerguson, 48 | lambda : cl.Benktander(n_iters=2), cl.CapeCod] 49 | 50 | @pytest.mark.parametrize('dev', dev) 51 | @pytest.mark.parametrize('tail', tail) 52 | @pytest.mark.parametrize('ibnr', ibnr) 53 | def test_pipeline(tri, dev, tail, ibnr): 54 | X = tri[['CumPaidLoss', 'CaseIncurredLoss']] 55 | sample_weight = tri['EarnedPremDIR'].latest_diagonal 56 | cl.Pipeline( 57 | steps=[('dev', dev()), ('tail', tail()), ('ibnr', ibnr())] 58 | ).fit_predict(X, sample_weight=sample_weight).ibnr_.sum('origin').sum('columns').sum() 59 | -------------------------------------------------------------------------------- /ci/environment-latest.yaml: -------------------------------------------------------------------------------- 1 | name: cl_latest 2 | 3 | channels: 4 | - defaults 5 | - conda-forge 6 | 7 | dependencies: 8 | - conda-forge::pandas>=2.0 9 | - polars 10 | - scikit-learn>=0.23 11 | - sparse>=0.9 12 | - numba 13 | - dill 14 | - patsy 15 | # testing 16 | - lxml 17 | - pytest 18 | - ipython 19 | - jinja2 20 | -------------------------------------------------------------------------------- /ci/environment-test.yaml: -------------------------------------------------------------------------------- 1 | # The basic requirements for CI testing of chainladder 2 | name: cl_test 3 | 4 | channels: 5 | - defaults 6 | - conda-forge 7 | 8 | dependencies: 9 | - pandas>=0.23 10 | - polars>=0.16.2 11 | - scikit-learn>=0.23 12 | - sparse>=0.9 13 | - numba 14 | - dill 15 | - patsy 16 | - dask 17 | 18 | # testing 19 | - lxml 20 | - pytest 21 | - pytest-cov 22 | - ipython 23 | - jinja2 24 | 25 | -------------------------------------------------------------------------------- /conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import chainladder as cl 3 | 4 | 5 | def pytest_generate_tests(metafunc): 6 | if "raa" in metafunc.fixturenames: 7 | metafunc.parametrize("raa", ["normal_run", "sparse_only_run"], indirect=True) 8 | if "qtr" in metafunc.fixturenames: 9 | metafunc.parametrize("qtr", ["normal_run", "sparse_only_run"], indirect=True) 10 | if "clrd" in metafunc.fixturenames: 11 | metafunc.parametrize("clrd", ["normal_run", "sparse_only_run"], indirect=True) 12 | if "genins" in metafunc.fixturenames: 13 | metafunc.parametrize("genins", ["normal_run", "sparse_only_run"], indirect=True) 14 | if "prism_dense" in metafunc.fixturenames: 15 | metafunc.parametrize( 16 | "prism_dense", ["normal_run", "sparse_only_run"], indirect=True 17 | ) 18 | if "prism" in metafunc.fixturenames: 19 | metafunc.parametrize("prism", ["normal_run"], indirect=True) 20 | if "xyz" in metafunc.fixturenames: 21 | metafunc.parametrize("xyz", ["normal_run", "sparse_only_run"], indirect=True) 22 | 23 | 24 | @pytest.fixture 25 | def raa(request): 26 | if request.param == "sparse_only_run": 27 | cl.options.set_option("ARRAY_BACKEND", "sparse") 28 | else: 29 | cl.options.set_option("ARRAY_BACKEND", "numpy") 30 | return cl.load_sample("raa") 31 | 32 | 33 | @pytest.fixture 34 | def qtr(request): 35 | if request.param == "sparse_only_run": 36 | cl.options.set_option("ARRAY_BACKEND", "sparse") 37 | else: 38 | cl.options.set_option("ARRAY_BACKEND", "numpy") 39 | return cl.load_sample("quarterly") 40 | 41 | 42 | @pytest.fixture 43 | def clrd(request): 44 | if request.param == "sparse_only_run": 45 | cl.options.set_option("ARRAY_BACKEND", "sparse") 46 | else: 47 | cl.options.set_option("ARRAY_BACKEND", "numpy") 48 | return cl.load_sample("clrd") 49 | 50 | 51 | @pytest.fixture 52 | def genins(request): 53 | if request.param == "sparse_only_run": 54 | cl.options.set_option("ARRAY_BACKEND", "sparse") 55 | else: 56 | cl.options.set_option("ARRAY_BACKEND", "numpy") 57 | return cl.load_sample("genins") 58 | 59 | 60 | @pytest.fixture 61 | def prism(request): 62 | cl.options.set_option("ARRAY_BACKEND", "numpy") 63 | return cl.load_sample("prism") 64 | 65 | 66 | @pytest.fixture 67 | def prism_dense(request): 68 | if request.param == "sparse_only_run": 69 | cl.options.set_option("ARRAY_BACKEND", "sparse") 70 | else: 71 | cl.options.set_option("ARRAY_BACKEND", "numpy") 72 | return cl.load_sample("prism").sum() 73 | 74 | 75 | @pytest.fixture 76 | def xyz(request): 77 | if request.param == "sparse_only_run": 78 | cl.options.set_option("ARRAY_BACKEND", "sparse") 79 | else: 80 | cl.options.set_option("ARRAY_BACKEND", "numpy") 81 | return cl.load_sample("xyz") 82 | 83 | 84 | @pytest.fixture 85 | def atol(): 86 | return 1e-4 87 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | # Book settings 2 | # Learn more at https://jupyterbook.org/customize/config.html 3 | 4 | title: Chainladder - Python 5 | author: John Bogaardt, Kenneth Hsu, et. al. 6 | logo: images/logo.png 7 | 8 | # Force re-execution of notebooks on each build. 9 | # See https://jupyterbook.org/content/execute.html 10 | execute: 11 | execute_notebooks: force 12 | 13 | # Define the name of the latex output file for PDF builds 14 | latex: 15 | latex_documents: 16 | targetname: book.tex 17 | 18 | # Add a bibtex file so that we can create citations 19 | bibtex_bibfiles: 20 | - library/references.bib 21 | 22 | # Information about where the book exists on the web 23 | repository: 24 | url: https://github.com/casact/chainladder-python # Online location of your book 25 | path_to_book: docs # Optional path to your book, relative to the repository root 26 | branch: master # Which branch of the repository should be used when creating links (optional) 27 | 28 | # Add GitHub buttons to your book 29 | # See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository 30 | html: 31 | use_issues_button: true 32 | use_repository_button: true 33 | 34 | sphinx: 35 | extra_extensions: 36 | - sphinx.ext.autodoc 37 | - sphinx.ext.autosummary 38 | - numpydoc 39 | - sphinx.ext.mathjax 40 | config: 41 | autosummary_generate: True 42 | bibtex_reference_style: author_year 43 | 44 | parse: 45 | myst_enable_extensions: 46 | - html_admonition 47 | - colon_fence 48 | -------------------------------------------------------------------------------- /docs/_toc.yml: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | # Learn more at https://jupyterbook.org/customize/toc.html 3 | 4 | format: jb-book 5 | root: intro.md 6 | 7 | parts: 8 | - chapters: 9 | - file: getting_started/index.md 10 | sections: 11 | - file: getting_started/online_sandbox/sandbox_intro.md 12 | sections: 13 | - file: getting_started/online_sandbox/sandbox_workbook_blank 14 | - file: getting_started/install.md 15 | - file: getting_started/tutorials/index.md 16 | sections: 17 | - file: getting_started/tutorials/triangle-tutorial.ipynb 18 | - file: getting_started/tutorials/development-tutorial.ipynb 19 | - file: getting_started/tutorials/tail-tutorial.ipynb 20 | - file: getting_started/tutorials/deterministic-tutorial.ipynb 21 | - file: getting_started/tutorials/stochastic-tutorial.ipynb 22 | - file: getting_started/tutorials/data-tutorial.ipynb 23 | - chapters: 24 | - file: user_guide/index.md 25 | sections: 26 | - file: user_guide/triangle.ipynb 27 | - file: user_guide/development.ipynb 28 | - file: user_guide/tails.ipynb 29 | - file: user_guide/methods.ipynb 30 | - file: user_guide/adjustments.ipynb 31 | - file: user_guide/workflow.ipynb 32 | - file: user_guide/utilities.ipynb 33 | - chapters: 34 | - file: gallery/index.md 35 | - chapters: 36 | - file: library/api.rst 37 | - chapters: 38 | - file: library/about.md 39 | sections: 40 | - file: library/usage.md 41 | - file: library/references.md 42 | - file: library/sample_data.md 43 | - file: library/glossary.md 44 | - file: library/questions_issues.md 45 | - file: library/contributing.md 46 | - file: library/roadmap.md 47 | - chapters: 48 | - file: library/releases.md -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # jupyter-book config sphinx . 2 | author = "" 3 | bibtex_bibfiles = ["./library/references.bib"] 4 | comments_config = {"hypothesis": False, "utterances": False} 5 | copyright = "2023" 6 | exclude_patterns = [ 7 | "**.ipynb_checkpoints", 8 | ".DS_Store", 9 | "Thumbs.db", 10 | "_build", 11 | "templates", 12 | ] 13 | execution_allow_errors = False 14 | execution_excludepatterns = [] 15 | execution_in_temp = False 16 | execution_timeout = 30 17 | extensions = [ 18 | "sphinx_design", 19 | "sphinx_togglebutton", 20 | "sphinx_copybutton", 21 | "myst_nb", 22 | "jupyter_book", 23 | "sphinx_thebe", 24 | "sphinx_comments", 25 | "sphinx_external_toc", 26 | "sphinx.ext.intersphinx", 27 | "sphinx_book_theme", 28 | "sphinx.ext.autodoc", 29 | "sphinx.ext.autosummary", 30 | "numpydoc", 31 | "sphinx.ext.mathjax", 32 | "sphinxcontrib.bibtex", 33 | "sphinx_jupyterbook_latex", 34 | "sphinx_copybutton", 35 | "sphinx_design", 36 | ] 37 | external_toc_exclude_missing = False 38 | external_toc_path = "_toc.yml" 39 | html_permalinks = True 40 | html_permalinks_icon = "¶" 41 | html_baseurl = "" 42 | html_favicon = "" 43 | html_logo = "./images/logo.png" 44 | html_sourcelink_suffix = "" 45 | html_theme = "sphinx_book_theme" 46 | html_theme_options = { 47 | "search_bar_text": "Search this book...", 48 | "launch_buttons": { 49 | "notebook_interface": "classic", 50 | "binderhub_url": "https://mybinder.org", 51 | "jupyterhub_url": "", 52 | "thebe": False, 53 | "colab_url": "", 54 | }, 55 | "path_to_docs": "docs", 56 | "repository_url": "https://github.com/casact/chainladder-python", 57 | "repository_branch": "master", 58 | "google_analytics_id": "", 59 | "extra_navbar": 'Powered by Jupyter Book', 60 | "extra_footer": "", 61 | "home_page_in_toc": True, 62 | "use_repository_button": True, 63 | "use_edit_page_button": False, 64 | "use_issues_button": True, 65 | } 66 | html_title = "Reserving in Python" 67 | jupyter_cache = "" 68 | jupyter_execute_notebooks = "force" 69 | language = "en" 70 | latex_engine = "pdflatex" 71 | myst_enable_extensions = ["colon_fence", "dollarmath", "linkify", "substitution"] 72 | myst_url_schemes = ["mailto", "http", "https"] 73 | nb_output_stderr = "show" 74 | numfig = True 75 | panels_add_bootstrap_css = False 76 | pygments_style = "sphinx" 77 | suppress_warnings = ["myst.domains"] 78 | use_jupyterbook_latex = True 79 | use_multitoc_numbering = True 80 | autosummary_generate = True 81 | nbsphinx_kernel_name = "cl_docs" 82 | 83 | 84 | import chainladder as cl 85 | 86 | version = cl.__version__ 87 | release = cl.__version__ 88 | -------------------------------------------------------------------------------- /docs/getting_started/index.md: -------------------------------------------------------------------------------- 1 | ## {octicon}`rocket` Getting Started 2 | 3 | We recommend that you try the sandbox tutorial before installing the package on your machine. There's also the more in-depth onboarding tutorial to give you a slightly more comprehensive view of what the package can do. 4 | 5 | ::::{grid} 1 2 3 4 6 | :gutter: 1 1 1 2 7 | 8 | :::{grid-item-card} {octicon}`chevron-right;2.5em;sd-mr-1` Try Online 9 | :link: online_sandbox/sandbox_intro 10 | :link-type: doc 11 | 12 | Try chainladder online. 13 | ::: 14 | 15 | :::{grid-item-card} {octicon}`desktop-download;2.5em;sd-mr-1` Installation 16 | :link: install 17 | :link-type: doc 18 | 19 | How to install chainladder. 20 | ::: 21 | 22 | :::{grid-item-card} {octicon}`beaker;2.5em;sd-mr-1` Tutorials 23 | :link: tutorials/index 24 | :link-type: doc 25 | 26 | Our beginner tutorials. 27 | ::: 28 | 29 | :::: 30 | -------------------------------------------------------------------------------- /docs/getting_started/install.md: -------------------------------------------------------------------------------- 1 | (installation-instructions)= 2 | # {octicon}`desktop-download` Installation 3 | We strongly encourage users to install chainladder in a dedicated environment, like a conda environment. 4 | 5 | ## General Installation 6 | There are two ways to install the chainladder package, using `pip` or `conda`: 7 | 8 | ````{tab-set} 9 | ```{tab-item} pip 10 | 11 | [![](https://badge.fury.io/py/chainladder.svg)](https://anaconda.org/conda-forge/chainladder) 12 | [![](https://pepy.tech/badge/chainladder)](https://pepy.tech/project/chainladder) 13 | 14 | 15 | Installing `chainladder` using `pip`: 16 | 17 | `pip install chainladder` 18 | 19 | Alternatively, if you have git and want to enjoy unreleased features, you can 20 | install directly from `Github`: 21 | 22 | `pip install git+https://github.com/casact/chainladder-python/` 23 | ``` 24 | 25 | ```{tab-item} conda 26 | 27 | [![](https://img.shields.io/conda/vn/conda-forge/chainladder.svg)](https://anaconda.org/conda-forge/chainladder) 28 | [![](https://img.shields.io/conda/dn/conda-forge/chainladder.svg)](https://anaconda.org/conda-forge/chainladder) 29 | 30 | 31 | Installing `chainladder` using `conda`: 32 | 33 | `conda install -c conda-forge chainladder` 34 | ``` 35 | ```` 36 | 37 | ## Developer Installation 38 | 39 | 40 | If you're interested in contributing, please refer to [Contributing](contributing) 41 | for information on the developer environment. 42 | -------------------------------------------------------------------------------- /docs/getting_started/online_sandbox/sandbox_intro.md: -------------------------------------------------------------------------------- 1 | # {octicon}`chevron-right` Try Online 2 | 3 | Before you go through the trouble of installing the package on your machine, why not give it a try online first? There's no reason to spend the time with setting up your dev enviroment, if you end up finding out that this is not useful to you. Save the time so you can spend it reconciling your data instead. 4 | 5 | If you are already familiar with a programming language, you should be able to get through this sandbox tutorial pretty quickly. While knowing python is not really required for this sandbox tutorial, you'll want to brush up your basic python skills before working on the more in depth Onboarding Tutorials following installation. 6 | 7 | This online sandbox tutorial is set up for you to "fill in the blanks". Basically, most of the code is already completed, except for a small piece of code in each line for you to fill in. It's up to you to figure out what goes in there, but we, the code volunteers are ready to answer any questions you may have, on GitHub. 8 | 9 | Time recommended: **1 hour** 10 | 11 | You can open the sandbox tutorial in one of two ways. You may be forced to use one or another, especially if you are a company network with strict network firewall rules. 12 | 13 | - Open in [Google Colab](https://githubtocolab.com/casact/chainladder-python/blob/master/docs/getting_started/online_sandbox/sandbox_workbook_blank.ipynb) (faster, but a free Google Account is required) 14 | 15 | - Open in [Binder](https://mybinder.org/v2/gh/casact/chainladder-python/master?urlpath=tree/docs/getting_started/online_sandbox/sandbox_workbook_blank.ipynb) (slower, no sign up required) 16 | 17 | Just in case you want a copy of the sandbox tutorial notebook, you can download it [here](https://github.com/casact/chainladder-python/blob/master/docs/getting_started/online_sandbox/sandbox_workbook_blank.ipynb). 18 | -------------------------------------------------------------------------------- /docs/getting_started/tutorials/index.md: -------------------------------------------------------------------------------- 1 | # {octicon}`beaker` Onboarding Tutorials 2 | 3 | These tutorials serve as the basic onboarding docs on how to use 4 | Chainladder. 5 | -------------------------------------------------------------------------------- /docs/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/logo.png -------------------------------------------------------------------------------- /docs/images/onlevel.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/onlevel.PNG -------------------------------------------------------------------------------- /docs/images/plot_advanced_triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_advanced_triangle.png -------------------------------------------------------------------------------- /docs/images/plot_ave_analysis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_ave_analysis.png -------------------------------------------------------------------------------- /docs/images/plot_benktander.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_benktander.png -------------------------------------------------------------------------------- /docs/images/plot_berqsherm_case.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_berqsherm_case.png -------------------------------------------------------------------------------- /docs/images/plot_bf_apriori_from_cl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_bf_apriori_from_cl.png -------------------------------------------------------------------------------- /docs/images/plot_bondy_sensitivity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_bondy_sensitivity.png -------------------------------------------------------------------------------- /docs/images/plot_bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_bootstrap.png -------------------------------------------------------------------------------- /docs/images/plot_bootstrap_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_bootstrap_comparison.png -------------------------------------------------------------------------------- /docs/images/plot_callable_dev_constant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_callable_dev_constant.png -------------------------------------------------------------------------------- /docs/images/plot_capecod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_capecod.png -------------------------------------------------------------------------------- /docs/images/plot_capecod_onlevel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_capecod_onlevel.png -------------------------------------------------------------------------------- /docs/images/plot_clarkldf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_clarkldf.png -------------------------------------------------------------------------------- /docs/images/plot_clarkldf_resid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_clarkldf_resid.png -------------------------------------------------------------------------------- /docs/images/plot_development_periods.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_development_periods.png -------------------------------------------------------------------------------- /docs/images/plot_elrf_resid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_elrf_resid.png -------------------------------------------------------------------------------- /docs/images/plot_exponential_smoothing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_exponential_smoothing.png -------------------------------------------------------------------------------- /docs/images/plot_exposure_triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_exposure_triangle.png -------------------------------------------------------------------------------- /docs/images/plot_extrap_period.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_extrap_period.png -------------------------------------------------------------------------------- /docs/images/plot_glm_ldf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_glm_ldf.png -------------------------------------------------------------------------------- /docs/images/plot_ibnr_runoff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_ibnr_runoff.png -------------------------------------------------------------------------------- /docs/images/plot_mack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_mack.png -------------------------------------------------------------------------------- /docs/images/plot_munich.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_munich.png -------------------------------------------------------------------------------- /docs/images/plot_munich_resid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_munich_resid.png -------------------------------------------------------------------------------- /docs/images/plot_ptf_resid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_ptf_resid.png -------------------------------------------------------------------------------- /docs/images/plot_stochastic_bornferg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_stochastic_bornferg.png -------------------------------------------------------------------------------- /docs/images/plot_tailcurve_compare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_tailcurve_compare.png -------------------------------------------------------------------------------- /docs/images/plot_triangle_from_pandas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_triangle_from_pandas.png -------------------------------------------------------------------------------- /docs/images/plot_triangle_slicing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_triangle_slicing.png -------------------------------------------------------------------------------- /docs/images/plot_value_at_risk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_value_at_risk.png -------------------------------------------------------------------------------- /docs/images/plot_voting_chainladder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/plot_voting_chainladder.png -------------------------------------------------------------------------------- /docs/images/prob_trend_family.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/prob_trend_family.PNG -------------------------------------------------------------------------------- /docs/images/triangle_bad_good.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/triangle_bad_good.PNG -------------------------------------------------------------------------------- /docs/images/triangle_graphic.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/casact/chainladder-python/37a0b882d50de1ef25725d37396a015c78fe26ad/docs/images/triangle_graphic.PNG -------------------------------------------------------------------------------- /docs/intro.md: -------------------------------------------------------------------------------- 1 | # {octicon}`home` Welcome 2 | 3 | Hello and welcome! 4 | 5 | The `chainladder-python` package was built to be able to handle all of your actuarial reserving needs in python. It consists of popular actuarial tools, such as **triangle data manipulation**, **link ratios calculation**, and **IBNR estimates** using both deterministic and stochastic models. We build this package so you no longer have to rely on outdated softwares and tools when performing actuarial pricing or reserving indications. 6 | 7 | This package strives to be minimalistic in needing its own API. The syntax mimics popular packages such as [pandas](https://pandas.pydata.org/) for data manipulation and [scikit-learn](https://scikit-learn.org/) for model construction. An actuary that is already familiar with these tools will be able to pick up this package with ease. You will be able to save your mental energy for actual actuarial work. 8 | 9 | ::::{grid} 1 2 2 4 10 | :gutter: 1 1 1 2 11 | 12 | :::{grid-item-card} {octicon}`rocket;2.5em;sd-mr-1` Getting Started 13 | :link: getting_started/index 14 | :link-type: doc 15 | 16 | Install chainladder and try the beginner tutorials. 17 | ::: 18 | 19 | :::{grid-item-card} {octicon}`book;2.5em;sd-mr-1` User Guide 20 | :link: user_guide/index 21 | :link-type: doc 22 | 23 | A more comprehensive guide on the capabilities of chainladder. 24 | ::: 25 | 26 | :::{grid-item-card} {octicon}`graph;2.5em;sd-mr-1` Galllery 27 | :link: gallery/index 28 | :link-type: doc 29 | 30 | Gallery of examples highlighting different use cases for chainladder. 31 | ::: 32 | 33 | :::{grid-item-card} {octicon}`code-square;2.5em;sd-mr-1` API Reference 34 | :link: library/api 35 | :link-type: doc 36 | 37 | The chainladder API Reference Manual provides a comprehensive reference for all methods. 38 | ::: 39 | 40 | :::: 41 | -------------------------------------------------------------------------------- /docs/library/about.md: -------------------------------------------------------------------------------- 1 | # {octicon}`heart` About -------------------------------------------------------------------------------- /docs/library/api.md: -------------------------------------------------------------------------------- 1 | # {octicon}`code-square` API Reference 2 | This is the class and function reference of chainladder. Please refer to 3 | the full user guide for further details, as the class and 4 | function raw specifications may not be enough to give full guidelines on their 5 | uses. 6 | 7 | ```{eval-rst} 8 | 9 | :mod:`chainladder.core`: Triangle 10 | ================================= 11 | 12 | .. automodule:: chainladder.core 13 | :no-members: 14 | :no-inherited-members: 15 | 16 | 17 | Classes 18 | ------- 19 | .. currentmodule:: chainladder 20 | 21 | .. autosummary:: 22 | :toctree: generated/ 23 | :template: class_inherited.rst 24 | 25 | Triangle 26 | DevelopmentCorrelation 27 | ValuationCorrelation 28 | 29 | 30 | .. _development_ref: 31 | 32 | :mod:`chainladder.development`: Development Patterns 33 | ==================================================== 34 | 35 | .. automodule:: chainladder.development 36 | :no-members: 37 | :no-inherited-members: 38 | 39 | 40 | Classes 41 | ------- 42 | .. currentmodule:: chainladder 43 | 44 | .. autosummary:: 45 | :toctree: generated/ 46 | :template: class.rst 47 | 48 | Development 49 | DevelopmentConstant 50 | MunichAdjustment 51 | IncrementalAdditive 52 | ClarkLDF 53 | CaseOutstanding 54 | TweedieGLM 55 | DevelopmentML 56 | BarnettZehnwirth 57 | 58 | 59 | .. _tails_ref: 60 | 61 | :mod:`chainladder.tails`: Tail Factors 62 | ======================================== 63 | 64 | .. automodule:: chainladder.tails 65 | :no-members: 66 | :no-inherited-members: 67 | 68 | 69 | Classes 70 | ------- 71 | .. currentmodule:: chainladder 72 | 73 | .. autosummary:: 74 | :toctree: generated/ 75 | :template: class.rst 76 | 77 | TailConstant 78 | TailCurve 79 | TailBondy 80 | TailClark 81 | 82 | 83 | .. _methods_ref: 84 | 85 | :mod:`chainladder.methods`: IBNR Methods 86 | ======================================== 87 | 88 | .. automodule:: chainladder.methods 89 | :no-members: 90 | :no-inherited-members: 91 | 92 | 93 | Classes 94 | ------- 95 | .. currentmodule:: chainladder 96 | 97 | .. autosummary:: 98 | :toctree: generated/ 99 | :template: class.rst 100 | 101 | Chainladder 102 | MackChainladder 103 | BornhuetterFerguson 104 | Benktander 105 | CapeCod 106 | 107 | .. _adjustments_ref: 108 | 109 | :mod:`chainladder.workflow`: Adjustments 110 | ======================================== 111 | .. automodule:: chainladder.workflow 112 | :no-members: 113 | :no-inherited-members: 114 | 115 | Classes 116 | ------- 117 | .. currentmodule:: chainladder 118 | 119 | .. autosummary:: 120 | :toctree: generated/ 121 | :template: class.rst 122 | 123 | BootstrapODPSample 124 | BerquistSherman 125 | Trend 126 | ParallelogramOLF 127 | 128 | .. _workflow_ref: 129 | 130 | :mod:`chainladder.workflow`: Workflow 131 | ===================================== 132 | .. automodule:: chainladder.workflow 133 | :no-members: 134 | :no-inherited-members: 135 | 136 | Classes 137 | ------- 138 | .. currentmodule:: chainladder 139 | 140 | .. autosummary:: 141 | :toctree: generated/ 142 | :template: class.rst 143 | 144 | Pipeline 145 | VotingChainladder 146 | GridSearch 147 | 148 | 149 | .. _utils_ref: 150 | 151 | :mod:`chainladder.utils`: Utilities 152 | =================================== 153 | .. automodule:: chainladder.utils 154 | :no-members: 155 | :no-inherited-members: 156 | 157 | 158 | Functions 159 | --------- 160 | .. currentmodule:: chainladder 161 | 162 | .. autosummary:: 163 | :toctree: generated/ 164 | :template: function.rst 165 | 166 | load_sample 167 | read_pickle 168 | read_json 169 | concat 170 | load_sample 171 | minimum 172 | maximum 173 | 174 | Classes 175 | ------- 176 | .. currentmodule:: chainladder 177 | 178 | .. autosummary:: 179 | :toctree: generated/ 180 | :template: class.rst 181 | 182 | PatsyFormula 183 | 184 | ``` -------------------------------------------------------------------------------- /docs/library/generated/chainladder.BarnettZehnwirth.rst: -------------------------------------------------------------------------------- 1 | chainladder.BarnettZehnwirth 2 | ============================ 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: BarnettZehnwirth -------------------------------------------------------------------------------- /docs/library/generated/chainladder.Benktander.rst: -------------------------------------------------------------------------------- 1 | chainladder.Benktander 2 | ====================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: Benktander -------------------------------------------------------------------------------- /docs/library/generated/chainladder.BerquistSherman.rst: -------------------------------------------------------------------------------- 1 | chainladder.BerquistSherman 2 | =========================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: BerquistSherman -------------------------------------------------------------------------------- /docs/library/generated/chainladder.BootstrapODPSample.rst: -------------------------------------------------------------------------------- 1 | chainladder.BootstrapODPSample 2 | ============================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: BootstrapODPSample -------------------------------------------------------------------------------- /docs/library/generated/chainladder.BornhuetterFerguson.rst: -------------------------------------------------------------------------------- 1 | chainladder.BornhuetterFerguson 2 | =============================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: BornhuetterFerguson -------------------------------------------------------------------------------- /docs/library/generated/chainladder.CapeCod.rst: -------------------------------------------------------------------------------- 1 | chainladder.CapeCod 2 | =================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: CapeCod -------------------------------------------------------------------------------- /docs/library/generated/chainladder.CaseOutstanding.rst: -------------------------------------------------------------------------------- 1 | chainladder.CaseOutstanding 2 | =========================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: CaseOutstanding -------------------------------------------------------------------------------- /docs/library/generated/chainladder.Chainladder.rst: -------------------------------------------------------------------------------- 1 | chainladder.Chainladder 2 | ======================= 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: Chainladder -------------------------------------------------------------------------------- /docs/library/generated/chainladder.ClarkLDF.rst: -------------------------------------------------------------------------------- 1 | chainladder.ClarkLDF 2 | ==================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: ClarkLDF -------------------------------------------------------------------------------- /docs/library/generated/chainladder.Development.rst: -------------------------------------------------------------------------------- 1 | chainladder.Development 2 | ======================= 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: Development -------------------------------------------------------------------------------- /docs/library/generated/chainladder.DevelopmentConstant.rst: -------------------------------------------------------------------------------- 1 | chainladder.DevelopmentConstant 2 | =============================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: DevelopmentConstant -------------------------------------------------------------------------------- /docs/library/generated/chainladder.DevelopmentCorrelation.rst: -------------------------------------------------------------------------------- 1 | chainladder.DevelopmentCorrelation 2 | ================================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: DevelopmentCorrelation -------------------------------------------------------------------------------- /docs/library/generated/chainladder.DevelopmentML.rst: -------------------------------------------------------------------------------- 1 | chainladder.DevelopmentML 2 | ========================= 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: DevelopmentML -------------------------------------------------------------------------------- /docs/library/generated/chainladder.GridSearch.rst: -------------------------------------------------------------------------------- 1 | chainladder.GridSearch 2 | ====================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: GridSearch -------------------------------------------------------------------------------- /docs/library/generated/chainladder.IncrementalAdditive.rst: -------------------------------------------------------------------------------- 1 | chainladder.IncrementalAdditive 2 | =============================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: IncrementalAdditive -------------------------------------------------------------------------------- /docs/library/generated/chainladder.MackChainladder.rst: -------------------------------------------------------------------------------- 1 | chainladder.MackChainladder 2 | =========================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: MackChainladder -------------------------------------------------------------------------------- /docs/library/generated/chainladder.MunichAdjustment.rst: -------------------------------------------------------------------------------- 1 | chainladder.MunichAdjustment 2 | ============================ 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: MunichAdjustment -------------------------------------------------------------------------------- /docs/library/generated/chainladder.ParallelogramOLF.rst: -------------------------------------------------------------------------------- 1 | chainladder.ParallelogramOLF 2 | ============================ 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: ParallelogramOLF -------------------------------------------------------------------------------- /docs/library/generated/chainladder.PatsyFormula.rst: -------------------------------------------------------------------------------- 1 | chainladder.PatsyFormula 2 | ======================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: PatsyFormula -------------------------------------------------------------------------------- /docs/library/generated/chainladder.Pipeline.rst: -------------------------------------------------------------------------------- 1 | chainladder.Pipeline 2 | ==================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: Pipeline -------------------------------------------------------------------------------- /docs/library/generated/chainladder.TailBondy.rst: -------------------------------------------------------------------------------- 1 | chainladder.TailBondy 2 | ===================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: TailBondy -------------------------------------------------------------------------------- /docs/library/generated/chainladder.TailClark.rst: -------------------------------------------------------------------------------- 1 | chainladder.TailClark 2 | ===================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: TailClark -------------------------------------------------------------------------------- /docs/library/generated/chainladder.TailConstant.rst: -------------------------------------------------------------------------------- 1 | chainladder.TailConstant 2 | ======================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: TailConstant -------------------------------------------------------------------------------- /docs/library/generated/chainladder.TailCurve.rst: -------------------------------------------------------------------------------- 1 | chainladder.TailCurve 2 | ===================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: TailCurve -------------------------------------------------------------------------------- /docs/library/generated/chainladder.Trend.rst: -------------------------------------------------------------------------------- 1 | chainladder.Trend 2 | ================= 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: Trend -------------------------------------------------------------------------------- /docs/library/generated/chainladder.Triangle.rst: -------------------------------------------------------------------------------- 1 | chainladder.Triangle 2 | ==================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: Triangle -------------------------------------------------------------------------------- /docs/library/generated/chainladder.TweedieGLM.rst: -------------------------------------------------------------------------------- 1 | chainladder.TweedieGLM 2 | ====================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: TweedieGLM -------------------------------------------------------------------------------- /docs/library/generated/chainladder.ValuationCorrelation.rst: -------------------------------------------------------------------------------- 1 | chainladder.ValuationCorrelation 2 | ================================ 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: ValuationCorrelation -------------------------------------------------------------------------------- /docs/library/generated/chainladder.VotingChainladder.rst: -------------------------------------------------------------------------------- 1 | chainladder.VotingChainladder 2 | ============================= 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autoclass:: VotingChainladder -------------------------------------------------------------------------------- /docs/library/generated/chainladder.concat.rst: -------------------------------------------------------------------------------- 1 | chainladder.concat 2 | ================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autofunction:: concat -------------------------------------------------------------------------------- /docs/library/generated/chainladder.load_sample.rst: -------------------------------------------------------------------------------- 1 | chainladder.load\_sample 2 | ======================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autofunction:: load_sample -------------------------------------------------------------------------------- /docs/library/generated/chainladder.maximum.rst: -------------------------------------------------------------------------------- 1 | chainladder.maximum 2 | =================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autofunction:: maximum -------------------------------------------------------------------------------- /docs/library/generated/chainladder.minimum.rst: -------------------------------------------------------------------------------- 1 | chainladder.minimum 2 | =================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autofunction:: minimum -------------------------------------------------------------------------------- /docs/library/generated/chainladder.read_json.rst: -------------------------------------------------------------------------------- 1 | chainladder.read\_json 2 | ====================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autofunction:: read_json -------------------------------------------------------------------------------- /docs/library/generated/chainladder.read_pickle.rst: -------------------------------------------------------------------------------- 1 | chainladder.read\_pickle 2 | ======================== 3 | 4 | .. currentmodule:: chainladder 5 | 6 | .. autofunction:: read_pickle -------------------------------------------------------------------------------- /docs/library/glossary.md: -------------------------------------------------------------------------------- 1 | # Glossary 2 | 3 | This glossary hopes to definitively represent the tacit and explicit 4 | conventions applied in `chanladder` and its API. 5 | 6 | ## General Terms 7 | 8 | backend 9 | - The storage of the numerical representation of a 10 | [Triangle]{.title-ref}. It can be 'numpy' for a dense CPU bound 11 | representation, 'sparse' for a sparse matrix CPU bound representation, 12 | or 'cupy' for a dense GPU bound representation. 13 | 14 | estimator 15 | - Any scikit-learn style class that can be `fit` to Triangle data. 16 | 17 | hyperparameter 18 | - An initial parameter of an estimator that can be set before the estimator is fit. 19 | 20 | predictor 21 | - An estimator that has the 22 | `predict` method. All IBNR estimators of `chainladder` are predictors 23 | 24 | transformer 25 | - An estimator that has the `transform` method. The transform 26 | method returns instances of a Triangle. All estimators 27 | other than IBNR estimators are transformers. 28 | 29 | ## Class API 30 | 31 | Triangle 32 | - The core data structure of the `chainladder` package. It emulates 33 | `pandas`'s functionality. 34 | 35 | Development 36 | - Transformers that produce, at a minimum, a multiplicative `ldf_` 37 | property. 38 | 39 | Tail 40 | - Transformers that extends the Development estimator properties 41 | beyond the edge of a Triangle. 42 | 43 | IBNR 44 | - Predictors that produce, at a minimum, an `ultimate_`, `ibnr_`, 45 | `full_expectation_` and `full_triangle_` property. 46 | 47 | Workflow 48 | - Meta-estimators that allow for composition of other estimators. 49 | 50 | Adjustments 51 | - Estimators that allow for the adjustment of the values of a 52 | Triangle. 53 | 54 | ## Triangle Concepts 55 | 56 | axis 57 | - Represents one of the four dimensions of a [Triangle]{.title-ref} 58 | instance. The four axes are `index`, `columns`, `origin` and 59 | `development`. `valuation` represents an additional axis implicit in 60 | the Triangle. 61 | 62 | index 63 | - The first axis of a 4D Triangle instance. Usually reserved for 64 | lines of business, or segments. 65 | 66 | columns 67 | - The second axis of a Triangle. 68 | 69 | origin 70 | - The third axis of a Triangle that represents origin dates of a Triangle. 71 | 72 | development 73 | - The fourth axis of a Triangle that represents either development age 74 | or valuation dates of a Triangle. 75 | 76 | valuation 77 | - An implicit axis representing the valuation period of each of the 78 | cells of a `Triangle`. 79 | -------------------------------------------------------------------------------- /docs/library/presentation_assets/concurrent_session.md: -------------------------------------------------------------------------------- 1 | # Concurrent Session 2 | 3 | Are you at the CAS Annual Meeting in Minneapolis? So are we! 4 | 5 | Below, you can find the materials referenced in the Concurrent Session. 6 | 7 | - [Presentation Deck](https://docs.google.com/presentation/d/13JtlCODvNjAF62SQyF_TLnvGk8FuBOOn4L3LeDqxjbQ/edit#slide=id.g14a01cc18bb_0_0) 8 | - [Lite Demo Workbook](https://github.com/casact/chainladder-python/blob/master/docs/library/2022_cas_annual_meeting/demo-blank-concurrent.ipynb) 9 | - Open in [Google Colab](https://githubtocolab.com/casact/chainladder-python/blob/master/docs/library/2022_cas_annual_meeting/demo-blank-concurrent.ipynb) (faster, Google Account required) 10 | - Open in [Binder](https://mybinder.org/v2/gh/casact/chainladder-python/master?urlpath=treedocs/library/2022_cas_annual_meeting/demo-blank-concurrent.ipynb) (slower, no sign up required) 11 | 12 | Other Resources: 13 | - [Chainladder-Python's GitHub](https://github.com/casact/chainladder-python/) 14 | - [CAS's GitHub](https://github.com/casact/) 15 | - [Actuarial Open Source](https://actuarialopensource.org/) 16 | - [The Actuary and IBNR Techniques: A Machine Learning Approach](https://deliverypdf.ssrn.com/delivery.php?ID=731070114084107029112030090019092127058062071092084057031006123078008013125027108099057029023099109125023090100018002120091125040057062033063080127003007019073011006073066010070116122002109103099127107020127111111065095019102084011005006064111002022121&EXT=pdf&INDEX=TRUE) by Caesar Balona & Ronald Richman 17 | - FASLR (Free Actuarial System for Loss Reserving): GUI of Chainladder-python by Gene Dan 18 | - [GitHub](https://github.com/casact/FASLR) 19 | - [Gene's Blog](https://genedan.com/) 20 | -------------------------------------------------------------------------------- /docs/library/presentation_assets/roundtable_session.md: -------------------------------------------------------------------------------- 1 | # Roundtable Session 2 | 3 | Are you going to the round table? Below is a list of things that we can cover, we will go through as many items as possible. 4 | 5 | Remember that you will need to bring your laptop, but there's nothing that you need to do before coming to the round table. 6 | 7 | 1. Re-work the [full demo workbook](https://github.com/casact/chainladder-python/blob/master/docs/tutorials/demo-blank.ipynb) from the Concurrent Session and complete the exercises 8 | 9 | - Open in [Google Colab](https://githubtocolab.com/casact/chainladder-python/blob/master/docs/tutorials/demo-blank.ipynb) (faster, Google Account required) 10 | - Open in [Binder](https://mybinder.org/v2/gh/casact/chainladder-python/master?urlpath=tree/docs/tutorials/demo-blank.ipynb) (slower, no sign up required) 11 | 12 | 2. [Install](https://chainladder-python.readthedocs.io/en/latest/library/install.html) the package on your computer 13 | 3. Work on the [onboarding tutorials](https://chainladder-python.readthedocs.io/en/latest/tutorials/tutorials_intro.html) 14 | -------------------------------------------------------------------------------- /docs/library/presentation_assets/webinar_demo.md: -------------------------------------------------------------------------------- 1 | # Presentation & Demo 2 | 3 | Are you for the CAS Webinar series? So are we! 4 | 5 | Below, you can find the materials referenced in the presentation. 6 | 7 | - [Presentation Deck](https://docs.google.com/presentation/d/1aEX7Df616hXxqa3s_mD5gzIg5X4rYnS_yc8wl1IaGaE/edit#slide=id.g14a01cc18bb_0_0) 8 | - [Demo Workbook](https://github.com/casact/chainladder-python/blob/master/docs/tutorials/demo-blank.ipynb) 9 | - Open in [Google Colab](https://githubtocolab.com/casact/chainladder-python/blob/master/docs/tutorials/demo-blank.ipynb) (faster, Google Account required) 10 | - Open in [Binder](https://mybinder.org/v2/gh/casact/chainladder-python/master?urlpath=treedocs/docs/tutorials/demo-blank.ipynb) (slower, no sign up required) 11 | 12 | Other Resources: 13 | - [Chainladder-Python's GitHub](https://github.com/casact/chainladder-python/) 14 | - [CAS's GitHub](https://github.com/casact/) 15 | - [Actuarial Open Source](https://actuarialopensource.org/) 16 | - [The Actuary and IBNR Techniques: A Machine Learning Approach](https://deliverypdf.ssrn.com/delivery.php?ID=731070114084107029112030090019092127058062071092084057031006123078008013125027108099057029023099109125023090100018002120091125040057062033063080127003007019073011006073066010070116122002109103099127107020127111111065095019102084011005006064111002022121&EXT=pdf&INDEX=TRUE) by Caesar Balona & Ronald Richman 17 | - FASLR (Free Actuarial System for Loss Reserving): GUI of Chainladder-python by Gene Dan 18 | - [GitHub](https://github.com/casact/FASLR) 19 | - [Gene's Blog](https://genedan.com/) 20 | -------------------------------------------------------------------------------- /docs/library/questions_issues.md: -------------------------------------------------------------------------------- 1 | # Questions & Issues 2 | 3 | Please visit the Chainladder-Python [Github](https://github.com/casact/chainladder-python) page. 4 | 5 | - If you have a question, please post your question in the [Discussions](https://github.com/casact/chainladder-python/discussions) forum on Github. 6 | 7 | 8 | - If you suspect a bug, please create a bug report in the [Issues](https://github.com/casact/chainladder-python/issues) forum on Github. 9 | 10 | - It would be extremely helpful if you also post your reproducible code with the required dataset. If you are unable to post your own data, try to use the data included within the package. 11 | -------------------------------------------------------------------------------- /docs/library/references.bib: -------------------------------------------------------------------------------- 1 | ```{bibliography} 2 | 3 | @article{mack1994, 4 | author = {Mack, T.}, 5 | title = {Measuring the {V}ariability of {C}hain {L}adder {R}eserve {E}stimates}, 6 | journal ={Variability of Loss Reserves}, 7 | year = {1994}, 8 | url = {https://www.casact.org/sites/default/files/2021-02/pubs_forum_94spforum_94spf101.pdf} 9 | } 10 | 11 | @article{barnett2000, 12 | author = {Barnett, G. and Zehnwirth, B.}, 13 | title = {Best {E}stimates for {R}eserves}, 14 | journal = {Proceedings of the CAS, Volume LXXXVII}, 15 | year = {2000}, 16 | url = {https://www.casact.org/sites/default/files/database/proceed_proceed00_00245.pdf} 17 | } 18 | 19 | @article{schmidt2006, 20 | author = {Schmidt, K.}, 21 | title = {Methods and {M}odels of {L}oss {R}eserving {B}ased on {R}un–{O}ff {T}riangles: {A} {U}nifying {S}urvey}, 22 | journal = { }, 23 | year = {2006}, 24 | url = {https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.376.544&rep=rep1&type=pdf} 25 | } 26 | 27 | @article{quarg2004, 28 | author = {Quarg, G. and Mack, T.}, 29 | title = {Munich {C}hain {L}adder: {A} {R}eserving {M}ethod that {R}educes the {G}ap between {IBNR}}, 30 | journal = {Variance}, 31 | year = {2004}, 32 | url = {https://www.casact.org/sites/default/files/2021-07/Munich-Chain-Ladder-Quarg-Mack.pdf} 33 | } 34 | 35 | @article{clark2003, 36 | author = {Clark, D.}, 37 | title = {LDF {C}urve-{F}itting and {S}tochastic {R}eserving: {A} {M}aximum {L}ikelihood {A}pproach}, 38 | journal = {Casualty Actuarial Society Forum}, 39 | year = {2003}, 40 | url = {https://www.casact.org/sites/default/files/database/forum_03fforum_03ff041.pdf} 41 | } 42 | 43 | @article{friedland2010, 44 | author = {Friedland, J.}, 45 | title = {Estimating {U}npaid {C}laims {U}sing {B}asic {T}echniques}, 46 | journal = {Casualty Actuarial Society, Ch. 12 , 7 , 9 , 10 & 13}, 47 | year = {2010}, 48 | url = {https://www.casact.org/sites/default/files/database/studynotes_friedland_estimating.pdf} 49 | } 50 | 51 | @article{taylor2016, 52 | author = {Taylor, G. and McGuire G.}, 53 | title = {Stochastic {L}oss {R}eserving {U}sing {G}eneralized {L}inear {M}odels}, 54 | journal = {Casualty Actuarial Society Monograph #3}, 55 | year = {2016}, 56 | url = {https://web.wpi.edu/Pubs/E-project/Available/E-project-042319-150245/unrestricted/03-Taylor.pdf} 57 | } 58 | 59 | @article{CAS_TFWP2013, 60 | author = {CAS Tail Factor Working Party}, 61 | title = {The {E}stimation of {L}oss {D}evelopment {T}ail {F}actors: {A} {S}ummary {R}eport}, 62 | journal = {Casualty Actuarial Society E-Forum}, 63 | year = {2013}, 64 | url = {https://www.casact.org/sites/default/files/database/forum_13fforum_02-tail-factors-working-party.pdf} 65 | } 66 | 67 | @article{mack1993, 68 | author = {Mack, T.}, 69 | title = {Distribution-{F}ree {C}alculation of {T}he {S}tandard {E}rror of {C}hain {L}adder {R}eserve {E}stimates}, 70 | journal = {ASTIN Bulletin, Vol. 23, No. 2, pp.213:225}, 71 | year = {1993}, 72 | url = {http://www.actuaries.org/LIBRARY/ASTIN/vol23no2/213.pdf} 73 | } 74 | 75 | @article{mack1999, 76 | author = {Mack, T.}, 77 | title = {The {S}tandard {E}rror of {C}hain {L}adder {R}eserve {E}stimates: {R}ecursive {C}alculation and {I}nclusion of a {T}ail {F}actor}, 78 | journal = {ASTIN Bulletin, Vol. 29, No. 2, pp.361:366}, 79 | year = {1999}, 80 | url = {https://www.casact.org/sites/default/files/database/astin_vol29no2_361.pdf} 81 | } 82 | 83 | @article{shapland2016, 84 | author = {Shapland, M.}, 85 | title = {Using {T}he {ODP} {B}ootstrap {M}odel: {A} {P}ractitioner's {G}uide}, 86 | journal = {CAS Monograph No.4 }, 87 | year = {2016}, 88 | url = {https://live-casact.pantheonsite.io/sites/default/files/2021-02/04-shapland.pdf} 89 | } 90 | -------------------------------------------------------------------------------- /docs/library/references.md: -------------------------------------------------------------------------------- 1 | # Relevant Papers 2 | 3 | Here you will find a list of reference papers that are cited in various places. 4 | 5 | ```{bibliography} 6 | ``` 7 | -------------------------------------------------------------------------------- /docs/library/roadmap.md: -------------------------------------------------------------------------------- 1 | # Roadmap 2 | 3 | There currently is no formal roadmap. 4 | 5 | ## Wish List 6 | 7 | - More tail estimators described by the CAS Tail Working Party 8 | - Parity with estimators in the R ChainLadder package 9 | - Expand, improve and seek independent review of stochastic estimators 10 | - Standardize vector-like hyper-parameters 11 | - Multi-core processing 12 | - Better GPU support 13 | - Better JSON support 14 | - Cleaner sub-triangle management 15 | - Automated testing of docs 16 | - Better dependency management 17 | -------------------------------------------------------------------------------- /docs/library/source_code.md: -------------------------------------------------------------------------------- 1 | # Source Code 2 | 3 | Please visit the Chainladder-Python [Github](https://github.com/casact/chainladder-python) page. 4 | -------------------------------------------------------------------------------- /docs/library/usage.md: -------------------------------------------------------------------------------- 1 | # Who Uses Chainladder-Python 2 | 3 | We are building out a list of companies that use the package. Please open a discussion ticket on GitHub or let any of the contributor know so we populate the list. 4 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | set SPHINXBUILD=sphinx-build 6 | set BUILDDIR=_build 7 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 8 | if NOT "%PAPER%" == "" ( 9 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 10 | ) 11 | 12 | if "%1" == "" goto help 13 | 14 | if "%1" == "help" ( 15 | :help 16 | echo.Please use `make ^` where ^ is one of 17 | echo. html to make standalone HTML files 18 | echo. dirhtml to make HTML files named index.html in directories 19 | echo. pickle to make pickle files 20 | echo. json to make JSON files 21 | echo. htmlhelp to make HTML files and a HTML help project 22 | echo. qthelp to make HTML files and a qthelp project 23 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 24 | echo. changes to make an overview over all changed/added/deprecated items 25 | echo. linkcheck to check all external links for integrity 26 | echo. doctest to run all doctests embedded in the documentation if enabled 27 | echo. html-noplot to make HTML files using Windows 28 | goto end 29 | ) 30 | 31 | if "%1" == "clean" ( 32 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 33 | del /q /s %BUILDDIR%\* 34 | goto end 35 | ) 36 | 37 | if "%1" == "html" ( 38 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 39 | echo. 40 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 41 | goto end 42 | ) 43 | 44 | if "%1" == "html-noplot" ( 45 | %SPHINXBUILD% -D plot_gallery=0 -b html %ALLSPHINXOPTS% %BUILDDIR%/html 46 | echo. 47 | echo.Build finished. The HTML pages are in %BUILDDIR%/html 48 | ) 49 | 50 | if "%1" == "dirhtml" ( 51 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 52 | echo. 53 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 54 | goto end 55 | ) 56 | 57 | if "%1" == "pickle" ( 58 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 59 | echo. 60 | echo.Build finished; now you can process the pickle files. 61 | goto end 62 | ) 63 | 64 | if "%1" == "json" ( 65 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 66 | echo. 67 | echo.Build finished; now you can process the JSON files. 68 | goto end 69 | ) 70 | 71 | if "%1" == "htmlhelp" ( 72 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 73 | echo. 74 | echo.Build finished; now you can run HTML Help Workshop with the ^ 75 | .hhp project file in %BUILDDIR%/htmlhelp. 76 | goto end 77 | ) 78 | 79 | if "%1" == "qthelp" ( 80 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 81 | echo. 82 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 83 | .qhcp project file in %BUILDDIR%/qthelp, like this: 84 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\scikit-learn.qhcp 85 | echo.To view the help file: 86 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\scikit-learn.ghc 87 | goto end 88 | ) 89 | 90 | if "%1" == "latex" ( 91 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 92 | echo. 93 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 94 | goto end 95 | ) 96 | 97 | if "%1" == "changes" ( 98 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 99 | echo. 100 | echo.The overview file is in %BUILDDIR%/changes. 101 | goto end 102 | ) 103 | 104 | if "%1" == "linkcheck" ( 105 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 106 | echo. 107 | echo.Link check complete; look for any errors in the above output ^ 108 | or in %BUILDDIR%/linkcheck/output.txt. 109 | goto end 110 | ) 111 | 112 | if "%1" == "doctest" ( 113 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 114 | echo. 115 | echo.Testing of doctests in the sources finished, look at the ^ 116 | results in %BUILDDIR%/doctest/output.txt. 117 | goto end 118 | ) 119 | 120 | :end 121 | -------------------------------------------------------------------------------- /docs/user_guide/index.md: -------------------------------------------------------------------------------- 1 | # {octicon}`book` User Guide 2 | 3 | Here are a few examples that we have came up with, hopefully the code is simple enough so you can fit your own needs. 4 | 5 | `````{grid} 6 | :gutter: 3 7 | 8 | ````{grid-item-card} 9 | :columns: 6 10 | 11 | **[Triangles](triangle)** 12 | ^^^ 13 | 14 | Data object to manage and manipulate reserving data 15 | 16 | **Application**: Extend pandas syntax to manipulate reserving triangles 17 | 18 | ```{glue:} plot_triangle_from_pandas 19 | ``` 20 | +++ 21 | **Classes**: **[Triangle](triangle)**, ... 22 | ```` 23 | 24 | ````{grid-item-card} 25 | :columns: 6 26 | 27 | **[Development](development)** 28 | ^^^ 29 | Tooling to generate loss development patterns 30 | 31 | **Applications**: Comprehensive library for development 32 | 33 | ```{glue:} plot_clarkldf 34 | ``` 35 | +++ 36 | 37 | **Algorithms**: [Development](development:development), [ClarkLDF](development:clarkldf), … 38 | 39 | ```` 40 | 41 | ````{grid-item-card} 42 | :columns: 6 43 | 44 | **[Tail Estimation](tails)** 45 | ^^^ 46 | Extrapolate development patterns beyond the known data. 47 | 48 | **Applications**: Long-tailed lines of business use cases 49 | 50 | ```{glue:} plot_exponential_smoothing 51 | ``` 52 | 53 | +++ 54 | **Algorithms**: [TailCurve](tails:tailcurve), [TailConstant](tails:tailconstant), … 55 | ```` 56 | 57 | ````{grid-item-card} 58 | :columns: 6 59 | 60 | **[IBNR Models](methods)** 61 | ^^^ 62 | 63 | Generate IBNR estimates and associated statistics 64 | 65 | 66 | **Applications**: Constructing reserve estimates 67 | 68 | ```{glue:} plot_mack 69 | ``` 70 | 71 | +++ 72 | **Algorithms**: [Chainladder](methods:chainladder), [CapeCod](methods:capecod), … 73 | ```` 74 | 75 | ````{grid-item-card} 76 | :columns: 6 77 | 78 | **[Adjustments](adjustments)** 79 | ^^^ 80 | Common actuarial data adjustments 81 | 82 | 83 | 84 | **Applications**: Simulation, trending, on-leveling 85 | 86 | ```{glue:} plot_stochastic_bornferg 87 | ``` 88 | 89 | +++ 90 | **Classes**: [BootstrapODPSample](adjustments:bootstrapodpsample), [Trend](adjustments:trend), … 91 | ```` 92 | 93 | ````{grid-item-card} 94 | :columns: 6 95 | 96 | **[Workflow](workflow)** 97 | ^^^ 98 | 99 | Workflow tools for complex analyses 100 | 101 | **Application**: Scenario testing, ensembling 102 | 103 | ```{glue:} plot_voting_chainladder 104 | ``` 105 | 106 | +++ 107 | **Utilities**: [Pipeline](workflow:pipeline), [VotingChainladder](workflow:votingchainladder), … 108 | ```` 109 | 110 | ````` 111 | -------------------------------------------------------------------------------- /environment-dev.yaml: -------------------------------------------------------------------------------- 1 | # The basic requirements for developing chainladder 2 | 3 | name: cl_dev 4 | 5 | channels: 6 | - defaults 7 | - conda-forge 8 | 9 | dependencies: 10 | - python 11 | - pip 12 | - git 13 | - ipython 14 | - ipykernel 15 | 16 | - pandas 17 | - scikit-learn 18 | - sparse 19 | - dill 20 | - patsy 21 | - matplotlib-base 22 | 23 | # testing 24 | - lxml 25 | - pytest 26 | - pytest-cov 27 | - pytest-xdist 28 | - jinja2 29 | 30 | - pip: 31 | - -e . -------------------------------------------------------------------------------- /environment-docs.yaml: -------------------------------------------------------------------------------- 1 | # The basic requirements for building the hosted docs 2 | name: cl_docs 3 | 4 | channels: 5 | - defaults 6 | - conda-forge 7 | 8 | dependencies: 9 | - python 10 | - pip 11 | - git 12 | 13 | - pandas 14 | - polars 15 | - scikit-learn 16 | - sparse 17 | - numba 18 | - dill 19 | - patsy 20 | - statsmodels 21 | - matplotlib 22 | 23 | # Docs 24 | - ipython 25 | - parso>=0.8 26 | - nbsphinx 27 | - numpydoc 28 | - nb_black 29 | 30 | - pip: 31 | - git+https://github.com/casact/chainladder-python/ 32 | - jupyter-book 33 | - sphinx-togglebutton 34 | -------------------------------------------------------------------------------- /readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | sphinx: 4 | configuration: docs/conf.py 5 | 6 | build: 7 | os: "ubuntu-20.04" 8 | tools: 9 | python: "mambaforge-4.10" 10 | jobs: 11 | pre_build: 12 | # Generate on-the-fly Sphinx configuration from Jupyter Book's _config.yml 13 | - "jupyter-book config sphinx docs/" 14 | 15 | 16 | conda: 17 | environment: environment-docs.yaml -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pandas>=2.0 2 | scikit-learn>1.4.2 3 | numba>0.54 4 | sparse>=0.9 5 | matplotlib 6 | dill 7 | patsy -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | from setuptools import setup, find_packages 6 | from os import listdir 7 | 8 | with open('requirements.txt', 'r') as f: 9 | dependencies = f.read().splitlines() 10 | 11 | with open("README.rst") as f: 12 | long_desc = f.read() 13 | 14 | descr = "Chainladder Package - P&C Loss Reserving package " 15 | name = 'chainladder' 16 | url = 'https://github.com/casact/chainladder-python' 17 | version='0.8.24' # Put this in __init__.py 18 | 19 | data_path = '' 20 | setup( 21 | name=name, 22 | version=version, 23 | maintainer='John Bogaardt', 24 | maintainer_email='jbogaardt@gmail.com', 25 | packages=find_packages(include=["chainladder", "chainladder.*"]), 26 | scripts=[], 27 | url=url, 28 | download_url='{}/archive/v{}.tar.gz'.format(url, version), 29 | license='MPL-2.0', 30 | include_package_data=True, 31 | package_data={ 32 | 'data': [data_path + item 33 | for item in listdir('chainladder{}'.format(data_path))]}, 34 | description=descr, 35 | long_description=long_desc, 36 | install_requires=dependencies, 37 | ) 38 | --------------------------------------------------------------------------------