Skip to content

docs: add BootstrapODPSample doctest examples#836

Merged
henrydingliu merged 2 commits into
casact:mainfrom
priyam0k:docs/704-bootstrap-examples
May 24, 2026
Merged

docs: add BootstrapODPSample doctest examples#836
henrydingliu merged 2 commits into
casact:mainfrom
priyam0k:docs/704-bootstrap-examples

Conversation

@priyam0k
Copy link
Copy Markdown
Contributor

@priyam0k priyam0k commented May 23, 2026

Adds a Sphinx doctest Examples section to the BootstrapODPSample class.

Refs #704 (Stochastic / Simulation → BootstrapODPSample row).

Summary of Changes

  • Adds an Examples block to BootstrapODPSample in chainladder/adjustments/bootstrap.py.
  • Three .. testcode:: / .. testoutput:: groups covering:
    1. Basic fit on the RAA sample — shows resampled_triangles_.shape and scale_.
    2. Downstream stochastic IBNR — Chainladder().fit(sims).ibnr_.sum('origin') aggregated to mean / std across 100 simulations.
    3. Parameter effect — drop_high=True shrinks scale_.
  • Uses random_state=42 and n_sims=100 so output is deterministic, fast, and stable across CI runners.
  • Docstring-only; no runtime logic or public API changes.

Related GitHub Issue(s)

Additional Context for Reviewers

  • Doctest CI passed locally and on GitHub Actions (Doctest (ubuntu-latest, 3.12)).

  • pytest chainladder/adjustments/tests -q → 16 passed.

  • Intentionally excludes .github/workflows/sync-main-to-docs.yml, matching the split-PR convention from docs: add tail estimator doctest examples #801.

  • Open to feedback on whether the IBNR example should also surface total_process_risk_ / total_parameter_risk_ from a paired MackChainladder view — happy to extend in a follow-up if useful.

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)


Note

Low Risk
Docstring-only documentation change; the only risk is doctest brittleness if numeric outputs or sampling behavior change across environments.

Overview
Adds a new Examples section to the BootstrapODPSample docstring with Sphinx doctests.

The examples show (1) deterministic fit output (resampled_triangles_.shape and scale_) on the RAA sample, (2) feeding bootstrap samples into Chainladder to summarize simulated IBNR mean/std, and (3) how drop_high=True changes the resulting scale_.

Reviewed by Cursor Bugbot for commit 48ab897. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds Sphinx doctest Examples section to the BootstrapODPSample class showing basic fit (resampled_triangles_.shape and scale_), downstream stochastic IBNR via Chainladder, and the effect of drop_high on scale_. Uses random_state=42 and n_sims=100 for deterministic, fast output.

Refs casact#704
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.94%. Comparing base (e76d85d) to head (48ab897).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #836   +/-   ##
=======================================
  Coverage   86.94%   86.94%           
=======================================
  Files          86       86           
  Lines        4994     4994           
  Branches      644      644           
=======================================
  Hits         4342     4342           
  Misses        462      462           
  Partials      190      190           
Flag Coverage Δ
unittests 86.94% <ø> (ø)

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/adjustments/bootstrap.py Outdated
51301.13
16149.47

Outlier link ratios can distort the residual distribution that the
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.

equating outlier with drop_high=True is not theoretically sound. can you pick any actual outlier to drop (may involve displaying and inspecting the ldf) or use a different rationale for using drop_high=True?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. You're right that drop_high=True is not an outlier test, so that wording was misleading. I'll rephrase it as a sensitivity check on the column maxima and push the fix shortly.

Rewords the paragraph introducing the drop_high=True example to describe it as a leave-one-out sensitivity check on the column maxima rather than outlier removal, since drop_high mechanically removes the column max without any outlier test.

Addresses review feedback on casact#836.
The estimator also supports a leave-one-out sensitivity check on the
residual distribution. Setting ``drop_high=True`` excludes the highest
link ratio in each development column before computing residuals, without
making any outlier judgement, so the resulting ``scale_`` measures how
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.

good to have international representation on this package

@henrydingliu henrydingliu merged commit 04e95f0 into casact:main May 24, 2026
10 checks passed
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.

2 participants