docs: add ClarkLDF doctest examples#802
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #802 +/- ##
=======================================
Coverage 88.79% 88.79%
=======================================
Files 89 89
Lines 5060 5060
Branches 646 646
=======================================
Hits 4493 4493
Misses 423 423
Partials 144 144
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
i went back and read a few pages from the pandas doc. a lot of them starts with a description of what a user is looking to accomplish, then goes through the details. but if we take the most curt example docstring I found on pandas, which is the xs function, the basic flow is still "user goal" -> "code implementation", rather than "in depth description of a parameter" -> "code implementation". could we do something similar with our examples? so instead of explaining the parameter, describe an issue then offer the parameter as the solution. |
e6eee62 to
9fc573e
Compare
| 1.917 | ||
| 1.912 | ||
|
|
||
| Provide exposure when the goal is a Cape Cod fit rather than a pure LDF |
There was a problem hiding this comment.
awkward phrasing. the intentionality of the user is to use cape cod. to use cape cod, the user can pass in a weight vector without additional parameters in the clarkldf transformer.
|
|
||
| .. testoutput:: | ||
|
|
||
| (6, 1) |
There was a problem hiding this comment.
the example text makes a claim about individual triangles being too sparse to fit. the actual code doesn't really make that apparent, or even show the results at all
| print(float(np.round(m_wei.ldf_.values[0, 0, 0, 0], 3))) | ||
|
|
||
| .. testoutput:: | ||
|
|
There was a problem hiding this comment.
too close to be a worthy choice of an example
|
@EKtheSage are you interested in finishing up this PR? |
- compare loglogistic and weibull fits on the full ldf_ pattern and on percent of ultimate emerged at 240 months to show that the curve choice drives the tail even when in-triangle factors nearly match - demonstrate Clark Cape Cod by passing a premium vector as sample_weight and printing the fitted expected loss ratios by line - show that clrd holds 775 company triangles and use groupby to pool them into one growth curve fit per line of business
|
@henrydingliu all three comments are addressed. The curve comparison now prints full ldf_ patterns plus the percent of ultimate emerged at 240 months (85% loglogistic versus 99% weibull), so the difference is material. The Cape Cod example now simply passes a premium vector as sample_weight on clrd data and prints the fitted ELRs by line. The groupby example shows the 775 company triangles being pooled into one curve fit per LOB with the fitted parameters. Main is merged in as well. |
Summary: Add focused ClarkLDF Sphinx doctest examples and make the numeric comparison robust to small platform/dependency drift by rounding the displayed LDF values. Split from the larger #786 work and intentionally excludes .github/workflows/sync-main-to-docs.yml. Refs #704
Note
Low Risk
Documentation-only change to the class docstring; no runtime or API behavior changes.
Overview
Adds a new Examples section to the
ClarkLDFclass docstring inclark.py, with three Sphinx doctest blocks and narrative aimed at actuaries.The first example fits loglogistic vs weibull on
ukmotor, prints rounded LDFs andG_(240)to show tail sensitivity, and explains curve choice. The second shows Cape Cod viasample_weightand documentsmethod_/elr_. The third usesgroupby="LOB"on theclrdsample to pool thin triangles and printomega_/theta_.There are no changes to estimator logic or public API—documentation and doctest coverage only.
Reviewed by Cursor Bugbot for commit 0377b04. Bugbot is set up for automated code reviews on this repo. Configure here.