docs: add workflow doctest examples#803
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #803 +/- ##
=======================================
Coverage 86.23% 86.23%
=======================================
Files 86 86
Lines 4947 4947
Branches 643 643
=======================================
Hits 4266 4266
Misses 484 484
Partials 197 197
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ) | ||
| param_grid = {"benk__n_iters": [1, 4]} | ||
| scoring = { | ||
| "IBNR": lambda m: float(np.nansum(m.named_steps.benk.ibnr_.values)) |
There was a problem hiding this comment.
could you please change this to sigma? we should look like we understand the basics of machine learning in the docstring.
| ) | ||
| pipe.set_params(dev__average="volume") | ||
| ib_volume = int( | ||
| round(float(np.nansum(pipe.fit_predict(tri).ibnr_.values)), 0) |
28e6914 to
b3dd40f
Compare
|
|
||
| import numpy as np | ||
|
|
||
| raa = cl.load_sample("raa") |
There was a problem hiding this comment.
a lot of duplicate code from previous example. hide under testsetup?
|
|
||
| .. testoutput:: | ||
|
|
||
| 19694.23 |
There was a problem hiding this comment.
confusing to the user to see one example with full vector of ultimates, followed by another example that only shows a couple
| 1989 20004.502125 | ||
| 1990 21605.832631 | ||
|
|
||
| ``weights`` and ``default_weighting`` change how sub-model ultimates are |
There was a problem hiding this comment.
narratively this doesn't build on the first example
| .. testoutput:: | ||
|
|
||
| 2 | ||
| 1.422 |
There was a problem hiding this comment.
@kennethshsu does this feel like a bug to you? going from simple avg to volume weighted somehow introduced such a gargantuan increase in sigma.
There was a problem hiding this comment.
I looked into this, and I don’t think this is a bug. Most of the sigma_ difference appears to be driven by the 12-24 factor.
Since the LDFs are shifting over time as we move down the origin years, the volume-weighted factors are being pulled toward the more recent origin years. That, in turn, is driving the larger sigma_ values relative to the older origin years.
That said, I’m not entirely sure what this example is intended to demonstrate. Also, summing the sigma_ values does not really seem meaningful here. I think it would make more sense to compare the underlying arrays directly.
|
|
||
| Examples | ||
| -------- | ||
| Use ``Pipeline`` when the same triangle should pass through several |
There was a problem hiding this comment.
this example doesn't motivate why pipeline is useful. said in another way, pipeline is overkill for a straightforward chainladder(development) on a single triangle.
one instructive narrative line would be to actually compare the groupby pipeline from the user guide to a pipeline without groupby
Summary: Add Sphinx doctest examples for GridSearch, Pipeline, and VotingChainladder workflow docs. Split from the larger #792 work and intentionally excludes .github/workflows/sync-main-to-docs.yml. Refs #704
Note
Low Risk
Docstring-only changes that add Sphinx doctest examples; low functional risk, with the main risk being brittle doctest outputs if sample data or numerical results change.
Overview
Adds doctest examples to the
GridSearchandPipelinedocstrings inworkflow/gridsearch.py, demonstrating parameter grid evaluation andstep__paramupdates in a fitted pipeline.Extends
VotingChainladderdocs inworkflow/voting.pywith an additional example showing howweights/default_weightingaffect blended ultimates, including expected printed outputs for Sphinx doctest.Reviewed by Cursor Bugbot for commit b3dd40f. Bugbot is set up for automated code reviews on this repo. Configure here.