Friedland Chapter 9 follow-up: loc/iloc setter, model persistence, Exhibits I and III#1112
Merged
henrydingliu merged 5 commits intoJul 12, 2026
Conversation
… + unpaid + reconciliation
…s) with 4 scenarios
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 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.
Summary of Changes
Follow-up to #1109 addressing Henry's review comments on Chapter 9 - Bornhuetter-Ferguson Technique. Three items:
tri * 0 + arrtrick in the a priori helper withd.iloc[0, 0] = np.asarray(vec, dtype=float).reshape(d.shape).Pipeline, saved withto_pickle, and recalled withcl.read_pickleinstead of refitting, so Chapter 9 reuses the Chapter 7 estimators.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
BornhuetterFergusonviaDevelopmentConstant(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,
BornhuetterFergusondriven viaDevelopmentConstant(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 aPipeline, saved withto_pickle, and reloaded withcl.read_picklebefore transform (instead of refitting inline).Exhibit III (U.S. PP Auto) adds four changing-conditions scenarios via a shared
pp_bf_scenariohelper (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.