DOCS: Add examples to deterministic IBNR methods (#704)#721
Open
EKtheSage wants to merge 1 commit intocasact:mainfrom
Open
DOCS: Add examples to deterministic IBNR methods (#704)#721EKtheSage wants to merge 1 commit intocasact:mainfrom
EKtheSage wants to merge 1 commit intocasact:mainfrom
Conversation
Adds doctest-validated Examples blocks to the five deterministic IBNR estimator classes, matching the Polars-style format used in PRs casact#714 and casact#719: no imports, "..." continuation lines, strict output indentation, and byte-exact output (no NORMALIZE_WHITESPACE). Per-class coverage: - Chainladder: class docstring, fit, predict - MackChainladder: class docstring, fit, predict (predict had no docstring before this PR), and five property docstrings written from scratch: full_std_err_, total_process_risk_, mack_std_err_, total_mack_std_err_, summary_ - BornhuetterFerguson: class docstring, fit, predict. Class docstring notes the apriori-as-Triangle requirement (a literal int sample_weight raises AttributeError) and explains the canonical "cl_ult * 0 + value" broadcasting idiom for building a flat per-origin apriori - Benktander: class docstring, fit, predict. Class docstring shows that n_iters interpolates between BF (n_iters=1) and chainladder (n_iters large) - CapeCod: class docstring, fit, predict. Class docstring contrasts CapeCod with BF/Benktander (sample_weight is exposure, apriori is derived) and demonstrates the trend and decay parameters All 20 example blocks validated with strict doctest.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #721 +/- ##
=======================================
Coverage 85.12% 85.12%
=======================================
Files 85 85
Lines 4909 4909
Branches 629 629
=======================================
Hits 4179 4179
Misses 521 521
Partials 209 209
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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this pull request do?
Addresses #704 for the deterministic IBNR estimator classes (the third tranche after #714 for the Triangle constructor and #719 for Triangle methods/properties).
Adds doctest-validated
Examplesblocks to the five deterministic estimator classes, matching the same Polars-style format established in #714 and #719: noimportstatements,...continuation prefixes, strict output indentation, and byte-exact output with noNORMALIZE_WHITESPACEflag.Coverage
chainladder.pyfit,predictmack.pyfit,predict(full new docstring — none existed before), plus full docstrings for the five Mack-specific properties:full_std_err_,total_process_risk_,mack_std_err_,total_mack_std_err_,summary_bornferg.pyfit,predictbenktander.pyfit,predictcapecod.pyfit,predictTotal: 20 doctest blocks.
Teaching points worth flagging
BornhuetterFergusonclass docstring documents the canonicalcl_ult * 0 + valueidiom for constructing a flat per-origin apriori.sample_weightmust be a chainladder Triangle, not a scalar; passingsample_weight=14000raisesAttributeError. New users hit this constantly.Benktanderclass docstring shows side-by-side thatn_iters=1reproduces Bornhuetter-Ferguson and increasingn_iterspulls the ultimates toward the chainladder estimate.CapeCodclass docstring contrasts the role ofsample_weight(exposure here, vs. apriori expected ultimate in BF/Benktander) and shows the effect oftrendanddecayon the derivedapriori_.MackChainladder.total_mack_std_err_docstring notes that the across-origin total exceeds the quadrature sum of per-originmack_std_err_because parameter risk is correlated across origins (each origin uses the same estimated age-to-age factors).Out of scope
Inherited methods from sklearn (
get_params,set_params,get_metadata_routing,set_fit_request,set_predict_request) and from chainladder mixins (intersection,set_backend,to_json,to_pickle, plus theCommonpropertiesibnr_,full_triangle_,full_expectation_,ldf_,latest_diagonal) are not documented here. The mixin methods are shared across many subclasses and warrant their own follow-up PR.Validation
All 20 example blocks were executed with Python's
doctestmodule in strict mode (noNORMALIZE_WHITESPACEflag) and pass with byte-exact output comparison.Relevent Github ticket(s)?
Issue #704. Companion to PRs #714 (constructor) and #719 (Triangle methods/properties).
Note
Low Risk
Documentation-only changes that add doctest-validated examples to several actuarial estimators; primary risk is brittle doctest output expectations affecting CI, with no runtime logic changes.
Overview
Adds doctest-validated
Examplesdocumentation to the deterministic IBNR estimatorsChainladder,BornhuetterFerguson,Benktander, andCapeCod, covering typicalfit/predictworkflows and key attributes likeultimate_,ibnr_, andapriori_.Expands
MackChainladderdocs with newpredictdocumentation and detailed example blocks for Mack-specific outputs (full_std_err_,total_process_risk_,mack_std_err_,total_mack_std_err_,summary_).Reviewed by Cursor Bugbot for commit 37beb69. Bugbot is set up for automated code reviews on this repo. Configure here.