adding support for multi-triangle in mackchainladder#873
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #873 +/- ##
==========================================
+ Coverage 87.04% 87.06% +0.02%
==========================================
Files 86 86
Lines 4986 4987 +1
Branches 646 646
==========================================
+ Hits 4340 4342 +2
+ Misses 456 455 -1
Partials 190 190
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@kennethshsu I'd like to take a shot at reviewing this one, I need to gain more experience at the actuarial parts of the package. |
|
All yours! Do you guys want to do a review roulette? So we all get about the same amount of PR to review? In addition to spreading the load, it'll also make the package more democratic. Maybe should be part of the CEP? |
There was a problem hiding this comment.
What happened here? Accident?
There was a problem hiding this comment.
i was trying to show gene that regular html doesn't automatically look as nice as ipynb. basically, trying to make .rst visually pleasing would be quite a feat.
There was a problem hiding this comment.
Ahh ok, I think I'd like a show & tell on this lol... I still don't know what's best.
Anyways I'll shut up here to not hijack the thread and let @genedan do the review.
There was a problem hiding this comment.
we'll have a basis to do a comparison once you are done with your notebook recreation of chapter 8.
|
I ran this little snippet to test out the new code and got some warnings: import chainladder as cl
clrd = cl.load_sample('clrd')
tri = clrd.loc['Agway Ins Co']['IncurLoss','CumPaidLoss']
mack = cl.MackChainladder().fit(tri)/home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:120: RuntimeWarning: overflow encountered in exp
sigma_ = xp.exp(time_pd * reg.slope_ + reg.intercept_)
/home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:124: RuntimeWarning: overflow encountered in exp
std_err_ = xp.exp(time_pd * reg.slope_ + reg.intercept_)
/home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:127: RuntimeWarning: invalid value encountered in multiply
sigma_ = sigma_ * 0
/home/ubuntu/Repos/chainladder-python/chainladder/tails/base.py:128: RuntimeWarning: invalid value encountered in multiply
std_err_ = std_err_* 0I didn't get them in the single-dimension case: raa = cl.load_sample('raa')
cl.MackChainladder().fit(raa)Out[25]: MackChainladder() |
|
I looked through |
|
I have some thoughts about handling warnings in general and how we can test for them, will put them in #840 and would like to hear yours too. |
that's because there's a boatload of empty triangles in clrd. tri = cl.load_sample('clrd').loc['Agway Ins Co']['IncurLoss','CumPaidLoss']
for i in range(len(tri.index)):
for j in range(len(tri.columns)):
cl.MackChainladder().fit(tri.iloc[i,j]) |
there is in the doctest. i can copy them into test_mack |
Summary of Changes
adding multi-triangle support for mackchainllader
removed a html sample from friedland chapter 7 that was accidentally left in during development
Related GitHub Issue(s)
closes #871
Additional Context for Reviewers
one line fix plus a new test to match
uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)Note
Medium Risk
Changes Mack standard-error weighting for multi-dimensional triangles; wrong results would affect reserve uncertainty, but scope is one line with a new parity test.
Overview
MackChainladder now builds the trailing weight slice in
_get_full_std_err_with shape matching the triangle’s index and column axes (val.shape[0],val.shape[1]) instead of a fixed(1, 1, …), so batch fits over multi-index triangles get correctfull_std_err_(and downstream Mack risk) per slice.A new test compares batch
full_std_err_on a multi-triangle CLRD sample to fitting each(index, column)slice alone. Friedland chapter 7 docs drop a stray HTML table and duplicate code block left from development; doctest output stays.Reviewed by Cursor Bugbot for commit d473402. Bugbot is set up for automated code reviews on this repo. Configure here.