From f4f08c053769fe7698d9083a9d0b553f09d6e758 Mon Sep 17 00:00:00 2001 From: John Bogaardt Date: Thu, 28 Nov 2019 17:47:00 -0700 Subject: [PATCH] docs update --- chainladder/__init__.py | 2 +- chainladder/core/tests/test_triangle.py | 11 +++++ docs/modules/classes.rst | 1 + docs/modules/development.rst | 55 +++++++++++++++++++++++++ docs/modules/triangle.rst | 17 +++++++- setup.py | 2 +- 6 files changed, 84 insertions(+), 4 deletions(-) diff --git a/chainladder/__init__.py b/chainladder/__init__.py index e3ca9010..14d1e78d 100644 --- a/chainladder/__init__.py +++ b/chainladder/__init__.py @@ -5,4 +5,4 @@ from chainladder.methods import * # noqa (API Import) from chainladder.workflow import * # noqa (API Import) -__version__ = '0.4.1' +__version__ = '0.4.2' diff --git a/chainladder/core/tests/test_triangle.py b/chainladder/core/tests/test_triangle.py index fdd8e58c..7f40aebd 100644 --- a/chainladder/core/tests/test_triangle.py +++ b/chainladder/core/tests/test_triangle.py @@ -248,3 +248,14 @@ def test_dropna(): clrd = cl.load_dataset('clrd') assert clrd.shape == clrd.dropna().shape assert clrd[clrd['LOB']=='wkcomp'].iloc[-5]['CumPaidLoss'].dropna().shape == (1,1,2,2) + +def test_commutative(): + tri = cl.load_dataset('quarterly') + full = cl.Chainladder().fit(tri).full_expectation_ + assert tri.grain('OYDY').val_to_dev() == tri.val_to_dev().grain('OYDY') + assert tri.cum_to_incr().grain('OYDY').val_to_dev() == tri.val_to_dev().cum_to_incr().grain('OYDY') + assert tri.grain('OYDY').cum_to_incr().val_to_dev().incr_to_cum() == tri.val_to_dev().grain('OYDY') + assert full.grain('OYDY').val_to_dev() == full.val_to_dev().grain('OYDY') + assert full.cum_to_incr().grain('OYDY').val_to_dev() == full.val_to_dev().cum_to_incr().grain('OYDY') + assert np.allclose(np.nan_to_num(full.grain('OYDY').cum_to_incr().val_to_dev().incr_to_cum().values), + np.nan_to_num(full.val_to_dev().grain('OYDY').values), atol=1e-5) \ No newline at end of file diff --git a/docs/modules/classes.rst b/docs/modules/classes.rst index b44b276d..647d8b39 100644 --- a/docs/modules/classes.rst +++ b/docs/modules/classes.rst @@ -50,6 +50,7 @@ Classes :template: class.rst Development + DevelopmentConstant MunichAdjustment BootstrapODPSample IncrementalAdditive diff --git a/docs/modules/development.rst b/docs/modules/development.rst index 4211d180..c81fbaee 100644 --- a/docs/modules/development.rst +++ b/docs/modules/development.rst @@ -7,6 +7,39 @@ Loss Development Patterns .. currentmodule:: chainladder +Estimators +=========== + +Fitting data: the main modeling API implemented by chainladder follows that of +the scikit-learn estimator. An estimator is any object that learns from data. + +All estimator objects expose a fit method that takes a `Triangle()` object: + +**Example:** + >>> estimator.fit(data) + +Estimator parameters: All the parameters of an estimator can be set when it is +instantiated or by modifying the corresponding attribute: + +**Example:** + >>> estimator = Estimator(param1=1, param2=2) + >>> estimator.param1 + 1 + +Estimated parameters: When data is fitted with an estimator, parameters are +estimated from the data at hand. All the estimated parameters are attributes +of the estimator object ending by an underscore: + +**Example:** +>>> estimator.estimated_param_ + +In many cases the estimated paramaters are themselves triangles and can be +manipulated using the same methods we learned about in the :class:`Triangle` class. + +**Example:** + >>> dev = cl.Development().fit(cl.load_dataset('ukmotor')) + >>> type(dev.cdf_) + .. _dev: @@ -49,6 +82,28 @@ of the 'drop' arguments is permissible. ``drop_high`` and ``drop_low`` are ignored in cases where the number of link ratios available for a given development period is less than 3. +Properties +---------- +:class:`Development` uses the regression approach suggested by Mack to estimate +development patterns. Using the regression framework, we not only get estimates +for our patterns (``cdf_``, and ``ldf_``), but also measures of variability of +our estimates (``sigma_``, ``std_err_``). These variability propeperties are +used to develop the stochastic featuers in the `MackChainladder()` method. + + +.. _dev_const: + +Constant +======== + +The :class:`DevelopmentConstant` method simply allows you to hard code development +patterns into a Development Estimator. A common example would be to include a +set of industry development patterns in your workflow that are not directly +estimated from any of your own data. + +For more info refer to the docstring of:class:`DevelopmentConstant`. + + .. _incremental: Incremental Additive diff --git a/docs/modules/triangle.rst b/docs/modules/triangle.rst index 7298625a..c983ec77 100644 --- a/docs/modules/triangle.rst +++ b/docs/modules/triangle.rst @@ -162,6 +162,7 @@ of these operations are legal. >>> x = raa[raa.origin>'1987-01-01'][raa.development<=36] >>> x = raa[raa.valuation>> import chainladder as cl >>> raa = cl.load_dataset('raa').dev_to_val() >>> raa.cum_to_incr()[raa.valuation>='1989'] - + 1989 1990 + 1981 54.0 172.0 + 1982 673.0 535.0 + 1983 649.0 603.0 + 1984 2658.0 984.0 + 1985 3786.0 225.0 + 1986 1233.0 2917.0 + 1987 6926.0 1368.0 + 1988 5596.0 6165.0 + 1989 3133.0 2262.0 + 1990 NaN 2063.0 + + Commutative methods ------------------- Where possible, the triangle methods are designed to be commutative. For example, diff --git a/setup.py b/setup.py index 1a051546..2d1c907b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ descr = "Chainladder Package - P&C Loss Reserving package " name = 'chainladder' url = 'https://github.com/jbogaardt/chainladder-python' -version='0.4.1' # Put this in __init__.py +version='0.4.2' # Put this in __init__.py data_path = '' setup(