Add Friedland Chapter 7 Jupyter notebook - #1189
Conversation
Hi @henrydingliu and @priyam0k , I attach my work-in-progress notebook for Ch. 7. It currently contains the following:
What remains to be done (which I am continuing to work on) is the following:
I have the following questions/observations to make based on my work so far:
If you agree that this is a bug or that the issue should be looked at further, I would be happy to take the appropriate steps. I had to supress this warning for the notebook to properly display some of the code without the warning.
Essentially, the default setting in Chainladder is to round HTML-rendered output to a prespecified number of decimal places for presentational quality depending on the average magnitude of the numbers (so based on the above the ldfs automatically round to 2 decimal places when rendered as HTML (which is what I think the notebook approach is doing). There are likely good reasons for the default display format above, but it does interfere with rendering of unrounded values in some circumstances (such as in the Jupyter notebook) and required a manual override. I raising this in case the default display code above needs to be reassessed.
I will send an update in the next couple of days, but in the meantime the work continues. |
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 @@
## main #1189 +/- ##
==========================================
- Coverage 91.48% 91.26% -0.22%
==========================================
Files 91 91
Lines 5552 5401 -151
Branches 736 691 -45
==========================================
- Hits 5079 4929 -150
Misses 338 338
+ Partials 135 134 -1
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:
|
|
one general comment first. if you are still working through things, keep the PR as a draft
it's an annoyance for sure. but we also value the transparency. just leave it there for the time being
keep the code visible. as for standardization, i think having a bit of variety actually gives our repo more character, i.e. we have a vibrant group of collaborators with different coding styles. there's some stuff we can standardize after we are through all the chapters. but not a priority for the time being.
just leave the rst for now. you can change the rst title to part I and have both parts on the toc |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e809abb. Configure here.
|
great progress on this @salexanian! since you're actively working through exhibit iv and the assertions, feel free to convert this to a draft PR so you don't feel rushed by review notifications. tag us whenever it's ready for final review! |
Thank you @priyam0k for this advice - I actually didn't know that I could that, and it would be very helpful to have it in draft as I complete Chapter 7. I will try and convert it to draft and might circle back to you if I hit a roadblock. |
|
@priyam0k , @henrydingliu finally finished Part II of Chapter 7. Asserts are done to reconcile with Friedland and all pass. Unfortunately, due to rounding errors, there is a $2.03 discrepancy between an entry in Friedland's and my versions of Exhibit III, Sheets 10/11 that required manual adjustment of the tolerance. The asserts are stored in a new file, friedland_assertions.py and the Friedland values are stored in serialized form in a .json file. |
|
@salexanian thanks for putting in so much work! could you please follow the convention as everyone else and put the entire assert source code directly into the notebook, without having to load other modules or jsons? |
btw we don't have to reconcile every single triangle and every single column. the key is reconciling estimated values. |
No problem, @henrydingliu . I will make those changes and circle back shortly. |
@henrydingliu, @priyam0k - it is done. |
Hi @priyam0k - I tried to round but no luck. Looking more closely at Exhibit IV, Sheet 6 in the Friedland text, note the following (in the upper steady state portion of the table):
In the lower changing product mix portion, I noted the following:
I have not looked at every entry, but the concerned me, particlarly given that columns 3 and 4 are not calculated columns (they are the data we are relying on). My guess is either Friedland's tables are incorrect (i.e. there are errors in her calculations), or else we do not have the raw data (i.e. the real data is of greater than integer precision and we only have integer-rounded values). What do you think about this? I guess if the point of these exhibits is really to ensure that no code updates to Chainladder cause it to deviate from the numeric calculations it currently makes (i.e. we are interested in enforcing relative accuracy rather than absolute accuracy), it does not matter and we could adjust figures close to zero, down to zero to conform to the exhibits. Please let me know your thoughts on this - I am uncertain what to do next. |
|
@salexanian thanks for the blazing fast revision! a couple of other comments
|
@salexanian friedland's textbook has known $1-$2 rounding errors from intermediate excel rounding when written. in this repo, Dynamically calculating values via chainladder-python is our main priority. we never hardcode figures to match textbook typos. using atol=3 in assert np.allclose() is our standard approach across docs for these rounding differences, so your assertion setup is good as-is! @henrydingliu if u would like to add anything on this? |
|
i try to only use 1e-n as atol. using an arbitrary number like 3 just because that's the largest diff we have seems too goal-seeky. i'd recommend using rtol = 1e-n in those instances. |
No problem, @henrydingliu - I will make these changes. For the Ex. 3 functions, I think I forgot to remove the metatag (I believe it is called |
No problem, @henrydingliu - I recall using an rtol in the 1e-5 range was enough due to the magnitude of the dollar values - I'll try this approach and send you and @priyam0k my results. |
@henrydingliu , I have unhidden the Ex3 functions and hid the assert blocks as per your original request (in issue #588). I will now study the |






Summary of Changes
This PR replaces the Chapter 7 .rst documentation with a Jupyter notebook.
Current progress:
-Migrated Exhibits I and II.
-Added Exhibit III.
-Updated the supporting data.
Remaining work includes:
-Exhibit IV.
-Assertions against Friedland.
-Formatting and notebook cleanup.
Related GitHub Issue(s)
#588
Additional Context for Reviewers
I will post a follow-up comment with several implementation observations and questions.
Checklist
uv run pytest) and documentation changes (uv run --directory docs jb build . --builder=custom --custom-builder=doctest)Note
Low Risk
Documentation navigation only; no runtime or library behavior changes in this diff.
Overview
Updates
docs/_toc.ymlso Friedland Chapter 7 is presented as two sibling sections instead of a single entry.The existing
friedland/chapter_7.rstpage is labeled Chapter 7 - Part I, and a newfriedland/chapter_7_part_2.ipynbpage is added to the Friedland section as Chapter 7 - Part II.Reviewed by Cursor Bugbot for commit 26b2665. Bugbot is set up for automated code reviews on this repo. Configure here.