Repository navigation
fix(development): preserve unweighted diagnostic ratios in CaseOutstanding (#1511) - #1550
Conversation
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): 0.0% fully typed (0 / 1)
Patch symbol details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1550 +/- ##
==========================================
+ Coverage 94.39% 94.59% +0.20%
==========================================
Files 98 98
Lines 6222 6233 +11
Branches 799 799
==========================================
+ Hits 5873 5896 +23
+ Misses 225 216 -9
+ Partials 124 121 -3
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:
|
|
Welcome to the repo @X6M-Work The fix and test look correct, preserves the unweighted diagnostic ratios cleanly without touching downstream selections. LGTM Just curious,how did you come across this issue or work in actuarial ? |
Thanks for the review and the welcome, i don’t work in actuarial science. I was looking for well described open bugs in Python projects, and your issue had a clear repro and expected behavior, which made it easy to pick up. I learned a bit about case outstanding development along the way. |
|
Glad the issue was easy to follow If you're looking for other Python-focused bugs with clear repros to pick up next, check out the Great First Contribution issues list. A couple of clean, self-contained ones open right now are #1481 ( |
Summary of Changes
Fixes #1511
This pull request ensures that diagnostic properties
paid_to_prior_case_andcase_to_prior_case_inCaseOutstandingpreserve unweighted historical ratios across all origin periods, matching the design ofDevelopment.link_ratio_.Root Cause
Previously,
case_to_prior_case_andpaid_to_prior_case_directly multiplied the computed ratios byself.case_w_andself.paid_w_. Whencase_n_periodsorpaid_n_periodswere specified, older historical origin periods were masked with0.0. This prevented inspection and review of historical ratios across the full triangle when tuning window lengths.Solution
chainladder/development/outstanding.py:self.case_w_fromcase_to_prior_case_and byself.paid_w_frompaid_to_prior_case_.fit(), multiplied the unweighted ratio triangles byself.case_w_andself.paid_w_before NaN conversion (num_to_nan) and computing the weighted selection averagescase_ldf_andpaid_ldf_.case_ldf_,paid_ldf_, and downstream projections) remain identical.test_unweighted_ratios_preserved_when_n_periods_setinchainladder/development/tests/test_outstanding.pyverifying that historical periods older thann_periodsare not masked with0.0and match the unweighted values of the full model.Verification & Validation
uv run pytest chainladder/development/tests/test_outstanding.py: 11/11 tests passed.uv run pytest chainladder/development/: 140/140 tests passed.