Skip to content

Friedland Chapter 9 follow-up: loc/iloc setter, model persistence, Exhibits I and III#1112

Merged
henrydingliu merged 5 commits into
casact:experimentalfrom
priyam0k:friedland/chapter-9-followup
Jul 12, 2026
Merged

Friedland Chapter 9 follow-up: loc/iloc setter, model persistence, Exhibits I and III#1112
henrydingliu merged 5 commits into
casact:experimentalfrom
priyam0k:friedland/chapter-9-followup

Conversation

@priyam0k

@priyam0k priyam0k commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Follow-up to #1109 addressing Henry's review comments on Chapter 9 - Bornhuetter-Ferguson Technique. Three items:

  • loc/iloc setter: replaced the tri * 0 + arr trick in the a priori helper with d.iloc[0, 0] = np.asarray(vec, dtype=float).reshape(d.shape).
  • model persistence: the XYZ development pattern is now built as a Pipeline, saved with to_pickle, and recalled with cl.read_pickle instead of refitting, so Chapter 9 reuses the Chapter 7 estimators.
  • Exhibits I and III: added Exhibit I (U.S. Industry Auto) and Exhibit III (U.S. PP Auto, four changing-conditions scenarios) next to the existing Exhibit II (XYZ). Notebook runs I to II to III with reconciliation asserts and outputs embedded.

Exhibit I reconciles exactly (IBNR 25,609,761 / 27,086,611 reported / paid). Exhibit III reconciles reported and paid for the Steady-State and Increasing Claim Ratios scenarios, and paid for all four.

Related GitHub Issue(s)

refers #588, follows #1109

Additional Context for Reviewers

  • Because the text rounds CDFs to 3 decimals, I feed the rounded CDFs into BornhuetterFerguson via DevelopmentConstant(style="cdf"). Without it the unrounded CDF drifts about 18k at U.S. Industry Auto magnitudes.

  • Rounding conventions differ per exhibit, matching the Friedland spreadsheets: Exhibit I rounds the LDF then cumulates (full-precision percentages), Exhibit III cumulates raw factors then rounds the percentages to 3 decimals.

  • Known data issue: the two case-outstanding scenarios (friedland_uspp_auto_increasing_case, friedland_uspp_increasing_claim_case) do not reconcile on the reported basis because those samples carry uncorrected data (salexanian's corrected CSVs on Reconcile data against Friedland's text used in Exam 5 #588 were not merged). The notebook flags this, and asserts cover reported for the two clean scenarios plus paid for all four. A separate PR to merge the corrected CSVs would let us tighten those asserts.

  • Chapter 9 is a notebook, so asserts run at build (execute_notebooks: force) and a failure surfaces as a warning, per the Chapter 11 convention.

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


Note

Low Risk
Documentation-only notebook changes with executable asserts; no production library or API surface changes in this diff.

Overview
Expands Friedland Chapter 9 (chapter_9.ipynb) from primarily Exhibit II (XYZ) to all three textbook exhibits, with reconciliation asserts and refreshed outputs.

Exhibit I (U.S. Industry Auto) is new: Chapter 7 development (3-year simple average, rounded LDFs/CDFs), Chapter 8 a priori expected claims, BornhuetterFerguson driven via DevelopmentConstant(style="cdf"), plus unpaid/IBNR tables and asserts against printed Exhibit I.

Exhibit II keeps the XYZ workflow but applies review follow-ups: a priori vectors are set with d.iloc[0, 0] = ... instead of zeroing via multiplication, and the Chapter 7 XYZ development selection is built as a Pipeline, saved with to_pickle, and reloaded with cl.read_pickle before transform (instead of refitting inline).

Exhibit III (U.S. PP Auto) adds four changing-conditions scenarios via a shared pp_bf_scenario helper (70% expected claim ratio, 5-year simple development, rounded % unreported/unpaid folded into effective CDFs). The notebook documents known sample-data gaps for two case-outstanding scenarios and asserts reported IBNR totals only where data is clean, plus paid IBNR for all four.

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

@github-actions

Copy link
Copy Markdown

Pyright Type Completeness

View the full pyright --verifytypes output for this commit

Project (full chainladder package, at this PR's head): 14.5% of exported symbols fully typed (185 / 1272)

Known Ambiguous Unknown Total
Project (head) 185 106 981 1272

Other symbols referenced but not exported by chainladder: 13

Known Ambiguous Unknown Total
Other (head) 3 1 9 13

Symbols without documentation:

  • Functions without docstring: 313
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected.

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.50%. Comparing base (d81951d) to head (95e5176).

Additional details and impacted files
@@              Coverage Diff              @@
##           experimental    #1112   +/-   ##
=============================================
  Coverage         90.50%   90.50%           
=============================================
  Files                91       91           
  Lines              5289     5289           
  Branches            671      671           
=============================================
  Hits               4787     4787           
  Misses              359      359           
  Partials            143      143           
Flag Coverage Δ
unittests 90.50% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

@henrydingliu henrydingliu merged commit 81636cb into casact:experimental Jul 12, 2026
11 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