Skip to content

docs: add workflow doctest examples#803

Open
EKtheSage wants to merge 2 commits into
casact:mainfrom
EKtheSage:docs/704-workflow-examples
Open

docs: add workflow doctest examples#803
EKtheSage wants to merge 2 commits into
casact:mainfrom
EKtheSage:docs/704-workflow-examples

Conversation

@EKtheSage
Copy link
Copy Markdown
Contributor

@EKtheSage EKtheSage commented May 16, 2026

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 GridSearch and Pipeline docstrings in workflow/gridsearch.py, demonstrating parameter grid evaluation and step__param updates in a fitted pipeline.

Extends VotingChainladder docs in workflow/voting.py with an additional example showing how weights/default_weighting affect 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.23%. Comparing base (72b270c) to head (b3dd40f).

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           
Flag Coverage Δ
unittests 86.23% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread chainladder/workflow/gridsearch.py Outdated
)
param_grid = {"benk__n_iters": [1, 4]}
scoring = {
"IBNR": lambda m: float(np.nansum(m.named_steps.benk.ibnr_.values))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please change this to sigma? we should look like we understand the basics of machine learning in the docstring.

Comment thread chainladder/workflow/gridsearch.py Outdated
)
pipe.set_params(dev__average="volume")
ib_volume = int(
round(float(np.nansum(pipe.fit_predict(tri).ibnr_.values)), 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need np here?

@EKtheSage EKtheSage force-pushed the docs/704-workflow-examples branch from 28e6914 to b3dd40f Compare May 17, 2026 04:20

import numpy as np

raa = cl.load_sample("raa")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a lot of duplicate code from previous example. hide under testsetup?


.. testoutput::

19694.23
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

narratively this doesn't build on the first example

.. testoutput::

2
1.422
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kennethshsu does this feel like a bug to you? going from simple avg to volume weighted somehow introduced such a gargantuan increase in sigma.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants