Skip to content

Friedland Chapter 11 - #1176

Open
henrydingliu wants to merge 30 commits into
mainfrom
chapter_11_parking
Open

Friedland Chapter 11#1176
henrydingliu wants to merge 30 commits into
mainfrom
chapter_11_parking

Conversation

@henrydingliu

@henrydingliu henrydingliu commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary of Changes

Adding a first draft of Chapter 11, which showcases the recently added TriangleWeight and DisposalRate

Unlike Chapter 6 and 7, we are using jupyter notebook, which provides richer formatting. Testing is achieved through asserts built into the notebook, though failing any assert only results in a warning.

RTD version here.

Related GitHub Issue(s)

refers #588
closes #1073 #1024

Additional Context for Reviewers

other misc edits:

  • adding precision to several gl insurer dataset (use severity x count to get more decimals on loss)

  • adding incremental paid severity to xyz dataset

  • removing friedland_xyz_disposal (redundant)

  • nan_triangle no longer returns full triangle for all patterns

  • w_ is now deleted inside _drop_subtriangles

  • TriangleWeight now supports full triangles

  • fit_OLS is fixed inside WeightedRegression; r-squared is added

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


Note

Medium Risk
Changes nan_triangle and TriangleWeight/WeightedRegression numerics affect development weighting and regression outputs; sample schema changes may break callers that depended on old columns or friedland_xyz_disp.

Overview
Adds Friedland Chapter 11 documentation (notebook + TOC) that walks through frequency–severity techniques using TriangleWeight, DisposalRate, WeightedRegression, and related workflows, with assert-based reconciliation to textbook figures.

TriangleWeight can now be fit on full triangles (e.g. full_triangle_): n_periods uses an X.is_full path that masks older origin periods instead of valuation filtering. fit normalizes sparse inputs to numpy/cupy backends, and w_ is cleared in _drop_subtriangles like other subtriangle attrs.

WeightedRegression weighted OLS now uses proper weighted means for slope/intercept and exposes rsq_ (used in the chapter for trend R²).

nan_triangle returns all-ones only for is_ultimate, not pattern triangles—pattern triangles get the valuation-based mask again.

Sample data: richer Friedland CSVs (Reported Claims, Incremental Paid Severity, refined reported amounts), manifest updates, and removal of redundant friedland_xyz_disp / its CSV.

Minor test/style cleanups plus new TriangleWeight tests for drop_valuation and full-triangle parity.

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

* WIP

* making progress

* promoting _param_property

* fixing bug

* full implementation w/ test

* bugbot and tests

* test fix

* rubric

* docstring and additional tests

* bugbot proof

* Update test_disposal.py

* docstring and additional tests

* bugbot proof

* Update test_disposal.py

* more bugbot fixes

* bug fix

* fix

* forcing numpy after all

* more fixes

* more fixes

* addressing reviewer comments

* added missing dependencies

* restructuring disposal attributes into mixin class

* adding `is_disposal_rate` attribute to triangle

* improving docstring and adding codecov coverage

* chapter 11 prep

* streamlining single dev weights

* doctest fixes

* additional tests
@github-actions

github-actions Bot commented Aug 1, 2026

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): 15.1% of exported symbols fully typed (209 / 1380)

Known Ambiguous Unknown Total
Project (head) 209 112 1059 1380

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: 325
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): 0.0% fully typed (0 / 3)

Known Ambiguous Unknown Total
Patch 0 1 2 3
Patch symbol details
Symbol Status Change
chainladder.utils.tests.test_utilities.test_triangleweight_drop_valuation_all ❌ unknown new
chainladder.utils.tests.test_utilities.test_triangleweight_full_triangle ❌ unknown new
chainladder.utils.weighted_regression.WeightedRegression.rsq_ ⚠️ ambiguous new

Comment thread chainladder/utils/triangle_weight.py Outdated
Comment thread chainladder/utils/triangle_weight.py Outdated
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.75%. Comparing base (e03d708) to head (9e98129).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1176      +/-   ##
==========================================
+ Coverage   91.70%   91.75%   +0.05%     
==========================================
  Files          93       93              
  Lines        5434     5447      +13     
  Branches      700      702       +2     
==========================================
+ Hits         4983     4998      +15     
+ Misses        327      326       -1     
+ Partials      124      123       -1     
Flag Coverage Δ
unittests 91.75% <100.00%> (+0.05%) ⬆️

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.

Comment thread docs/friedland/chapter_11.ipynb Outdated
Comment thread chainladder/utils/data/friedland_auto_freq_sev.csv Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fe37feb. Configure here.

Comment thread chainladder/utils/triangle_weight.py Outdated
@henrydingliu
henrydingliu marked this pull request as ready for review August 3, 2026 08:54
@kennethshsu

Copy link
Copy Markdown
Member

@henrydingliu is someone reviewing this one? We waiting on something?

@henrydingliu

Copy link
Copy Markdown
Member Author

is someone reviewing this one?

no

We waiting on something?

ruff just reran. will try to address it today

@kennethshsu

Copy link
Copy Markdown
Member

Ok cool, I can review this one whenever you are ready.

I'll also work on that PR reviewer roulette so we know exactly who owns what, the currently system is so messy because we don't know who's assigned.

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.

[BUG] nan_triangle returns full triangle when is_pattern

2 participants