docs: add BootstrapODPSample doctest examples#836
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
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:
|
| 51301.13 | ||
| 16149.47 | ||
|
|
||
| Outlier link ratios can distort the residual distribution that the |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
good to have international representation on this package
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 #836.
* Improved docstring and added examples * Added the link ratios * docs: add doctest examples for correlation classes Adds Sphinx doctest Examples sections to DevelopmentCorrelation and ValuationCorrelation. Each example opens with the Mack chain-ladder assumption being tested, prints the full decision signal (statistic, confidence band, and boolean) rather than a single boolean, and ties the result back to the chain-ladder workflow. Refs #704 * docs: add BootstrapODPSample doctest examples 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 #704 * docs: reframe drop_high example as sensitivity check 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 #836. * docs: move per-diagonal vs total mode note between testcode blocks Per @henrydingliu review on #844: opening paragraph now scoped to the calendar-effect concept; the per-diagonal vs whole-triangle distinction is introduced as a transition between the two testcode blocks. Refs #704 * docs: add README documenting docs build sources and outputs (refs #845) * docs: remove autosummary-generated API stubs and gitignore them (refs #846) These .rst files under docs/library/generated/ are emitted by sphinx.ext.autosummary on every build (autosummary_generate = True in docs/conf.py, driven by the :toctree: generated/ directives in docs/library/api.md). Committing them is redundant and out of sync with the rest of the build. Adds docs/library/generated/ to .gitignore so future builds do not stage them. Refs parent #841. * Added the transformed link ratio triangle using fit_transform to examples * Removed the multiple testouputs * docs: address review feedback on docs README (refs #845) - Drop the jb build internals + duplicate warnings note (kennethshsu) - Rename 'tutorial notebooks' to 'onboarding and Quickstart notebooks' (kennethshsu) - Drop the 'What to edit for which part of the site' table and 'Known issues' section as redundant with the Source files table and #841 (kennethshsu) * [REFACTOR]: Remove repetitive code. Remove dead Python 3.8 code. Add missing unit tests. * [FIX]: Limit test to only those values meant to be changed. Use realistic values for changed options. * [DOCS]: Finish updating Options docstring. * [FIX]: Fix ending state of test. * [FIX]: Reset backend after sparse-only run. * [REFACTOR] Create template fixture for sample data sets. * [Fix]: Remove duplicate fixture. * [REFACTOR]: Move datetime defaults out of Options. Add validation to option getters and setters. Deprecate cl.array_backend() and cl.auto_sparse() * FIX: Apply Bugbot fix. * FIX: Apply Bugbot fix. * FIX: Apply Bugbot fix. * DOCS: Add docstring, clean up test. * DOCS: Update docstring. * Friedland Chapter 6 and half of Chapter 7 (#837) first batch of deliverables for friedland reconstruction --------- Co-authored-by: Kenneth Hsu <kennethshsu@gmail.com> Co-authored-by: Gene Dan <genedan@gmail.com> Co-authored-by: henrydingliu <106109320+henrydingliu@users.noreply.github.com>
* Improved docstring and added examples * Added the link ratios * docs: add doctest examples for correlation classes Adds Sphinx doctest Examples sections to DevelopmentCorrelation and ValuationCorrelation. Each example opens with the Mack chain-ladder assumption being tested, prints the full decision signal (statistic, confidence band, and boolean) rather than a single boolean, and ties the result back to the chain-ladder workflow. Refs #704 * docs: add BootstrapODPSample doctest examples 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 #704 * docs: reframe drop_high example as sensitivity check 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 #836. * docs: move per-diagonal vs total mode note between testcode blocks Per @henrydingliu review on #844: opening paragraph now scoped to the calendar-effect concept; the per-diagonal vs whole-triangle distinction is introduced as a transition between the two testcode blocks. Refs #704 * docs: add README documenting docs build sources and outputs (refs #845) * Added the transformed link ratio triangle using fit_transform to examples * Removed the multiple testouputs * docs: address review feedback on docs README (refs #845) - Drop the jb build internals + duplicate warnings note (kennethshsu) - Rename 'tutorial notebooks' to 'onboarding and Quickstart notebooks' (kennethshsu) - Drop the 'What to edit for which part of the site' table and 'Known issues' section as redundant with the Source files table and #841 (kennethshsu) * [REFACTOR]: Remove repetitive code. Remove dead Python 3.8 code. Add missing unit tests. * [FIX]: Limit test to only those values meant to be changed. Use realistic values for changed options. * [DOCS]: Finish updating Options docstring. * [FIX]: Fix ending state of test. * [FIX]: Reset backend after sparse-only run. * [REFACTOR] Create template fixture for sample data sets. * [Fix]: Remove duplicate fixture. * [REFACTOR]: Move datetime defaults out of Options. Add validation to option getters and setters. Deprecate cl.array_backend() and cl.auto_sparse() * FIX: Apply Bugbot fix. * FIX: Apply Bugbot fix. * FIX: Apply Bugbot fix. * DOCS: Add docstring, clean up test. * DOCS: Update docstring. * Friedland Chapter 6 and half of Chapter 7 (#837) first batch of deliverables for friedland reconstruction * Delete docs/library/generated/chainladder.Development.rst --------- Co-authored-by: Kenneth Hsu <kennethshsu@gmail.com> Co-authored-by: priyam0k <87162535+priyam0k@users.noreply.github.com> Co-authored-by: Gene Dan <genedan@gmail.com>
Adds a Sphinx doctest
Examplessection to theBootstrapODPSampleclass.Refs #704 (Stochastic / Simulation → BootstrapODPSample row).
Summary of Changes
Examplesblock toBootstrapODPSampleinchainladder/adjustments/bootstrap.py... testcode::/.. testoutput::groups covering:fiton the RAA sample — showsresampled_triangles_.shapeandscale_.Chainladder().fit(sims).ibnr_.sum('origin')aggregated to mean / std across 100 simulations.drop_high=Trueshrinksscale_.random_state=42andn_sims=100so output is deterministic, fast, and stable across CI runners.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 pairedMackChainladderview — 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
Examplessection to theBootstrapODPSampledocstring with Sphinx doctests.The examples show (1) deterministic
fitoutput (resampled_triangles_.shapeandscale_) on the RAA sample, (2) feeding bootstrap samples intoChainladderto summarize simulated IBNR mean/std, and (3) howdrop_high=Truechanges the resultingscale_.Reviewed by Cursor Bugbot for commit 48ab897. Bugbot is set up for automated code reviews on this repo. Configure here.