From fb34a160b4b24d520455dadffa1b7962980080a8 Mon Sep 17 00:00:00 2001 From: Ethan Kang Date: Sat, 16 May 2026 01:17:52 -0700 Subject: [PATCH 1/2] docs: add ClarkLDF doctest examples --- chainladder/development/clark.py | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/chainladder/development/clark.py b/chainladder/development/clark.py index f8e1db17..c2641e82 100644 --- a/chainladder/development/clark.py +++ b/chainladder/development/clark.py @@ -54,6 +54,58 @@ class ClarkLDF(DevelopmentBase): norm_resid_: Triangle The "Normalized" Residuals of the model according to Clark. + Examples + -------- + ``growth`` selects the incremental curve; the first LDF cell moves slightly + between ``loglogistic`` (default) and ``weibull``. + + .. testsetup:: + + import chainladder as cl + + .. testcode:: + + import numpy as np + + tri = cl.load_sample("ukmotor") + m_log = cl.ClarkLDF(growth="loglogistic").fit(tri) + m_wei = cl.ClarkLDF(growth="weibull").fit(tri) + print(float(np.round(m_log.ldf_.values[0, 0, 0, 0], 3))) + print(float(np.round(m_wei.ldf_.values[0, 0, 0, 0], 3))) + + .. testoutput:: + + 1.917 + 1.912 + + Passing ``sample_weight`` switches to Cape Cod: ``method_`` becomes + ``cape_cod`` and ``elr_`` is estimated. + + .. testcode:: + + tri = cl.load_sample("ukmotor") + m = cl.ClarkLDF().fit(tri, sample_weight=tri * 0 + 1e7) + print(m.method_) + print(float(np.round(m.elr_.values[0, 0], 6))) + + .. testoutput:: + + cape_cod + 0.002002 + + ``groupby`` pools index levels before fitting so one parameter set is + returned per group (here, line of business on ``clrd``). + + .. testcode:: + + clrd = cl.load_sample("clrd").groupby("LOB")[["IncurLoss"]].sum() + m = cl.ClarkLDF(groupby="LOB").fit(clrd) + print(m.theta_.shape) + + .. testoutput:: + + (6, 1) + """ def __init__( From 9fc573e094c3eb115ba34a72aa626be434ae89a1 Mon Sep 17 00:00:00 2001 From: Ethan Kang Date: Sat, 16 May 2026 15:53:05 -0700 Subject: [PATCH 2/2] docs: frame ClarkLDF examples around user goals --- chainladder/development/clark.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/chainladder/development/clark.py b/chainladder/development/clark.py index c2641e82..269e9016 100644 --- a/chainladder/development/clark.py +++ b/chainladder/development/clark.py @@ -56,8 +56,9 @@ class ClarkLDF(DevelopmentBase): Examples -------- - ``growth`` selects the incremental curve; the first LDF cell moves slightly - between ``loglogistic`` (default) and ``weibull``. + Compare curve families when the selected growth curve materially affects + the fitted development pattern. The same triangle can be fit with the + default loglogistic curve or with the Weibull curve. .. testsetup:: @@ -78,8 +79,9 @@ class ClarkLDF(DevelopmentBase): 1.917 1.912 - Passing ``sample_weight`` switches to Cape Cod: ``method_`` becomes - ``cape_cod`` and ``elr_`` is estimated. + Provide exposure when the goal is a Cape Cod fit rather than a pure LDF + fit. Passing ``sample_weight`` changes ``method_`` to ``cape_cod`` and + estimates ``elr_``. .. testcode:: @@ -93,8 +95,9 @@ class ClarkLDF(DevelopmentBase): cape_cod 0.002002 - ``groupby`` pools index levels before fitting so one parameter set is - returned per group (here, line of business on ``clrd``). + Pool similar segments before fitting when each individual triangle is too + sparse for separate curve parameters. Here line of business produces one + parameter set per ``LOB``. .. testcode::