fix and enhance utils.model_diagnostics (#913)#914
Conversation
* fix and enhance utils.model_diagnostics * bugbot fix * adding test * bugbot fix * bugbot fix * bugbot fix and docstring * more tests * fixing test * fixing test * fixing test
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 bcb9d6b. Configure here.
| if groupby is not None: | ||
| out["IBNR"] = obj.ibnr_[col].groupby(groupby).sum() | ||
| else: | ||
| out["IBNR"] = obj.ibnr_[col] |
There was a problem hiding this comment.
Groupby IBNR Latest mismatch
Medium Severity
With groupby, Latest comes from a grouped copy of the data triangle while IBNR still flows through ibnr_, which subtracts a latest diagonal from ungrouped X_. Ultimate is aggregated separately, so exhibit rows can break IBNR = Ultimate - Latest even after summing ibnr_ by group.
Reviewed by Cursor Bugbot for commit bcb9d6b. Configure here.
There was a problem hiding this comment.
@cursoragent are you sure? ibnr_ is a property, not a static value
There was a problem hiding this comment.
Unable to authenticate your request. Please make sure to connect your GitHub account to Cursor. Go to Cursor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #914 +/- ##
==========================================
+ Coverage 88.16% 88.42% +0.26%
==========================================
Files 87 87
Lines 4952 4969 +17
Branches 629 635 +6
==========================================
+ Hits 4366 4394 +28
+ Misses 443 436 -7
+ Partials 143 139 -4
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 isn't true. The new align_ldf method is a direct copy/paste of the previous _align_cdf method. There is no behavior change. |


Summary of Changes
As we work our way through Friedland, the community agreed that we need a way to easily assemble exhibits together. Fortunately, John already created a
model_diagnosticsutility function._align_cdffunction fromMethodBasetoTriangle._align_cdfdid not need any information from the IBNR estimator and actually made more sense to be a triangle methodRelated GitHub Issue(s)
closes #839
Additional Context for Reviewers
uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)Note
Medium Risk
Changes affect a shared reporting helper and refactor CDF alignment used by several IBNR methods; fixes are behavior-changing for Latest/groupby outputs but are covered by new tests.
Overview
model_diagnosticsis reworked so exhibit-style summaries are more accurate and flexible: Latest is built from incremental development (fixing cumulative sums), predictedTriangleinputs are supported,groupbyno longer breaks IBNR, and LDF / CDF columns are added when not grouping (via pattern alignment).The CDF alignment logic moves from
MethodBase._align_cdftoTriangle.align_pattern, which_align_cdfnow delegates to; non-pattern triangles raiseValueError.Benktander
predictnow requiressample_weight, matchingfit. Tests are consolidated (parametrized predict/weights) and extended for diagnostics,align_pattern, and groupby consistency.Reviewed by Cursor Bugbot for commit bcb9d6b. Bugbot is set up for automated code reviews on this repo. Configure here.